Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

extract accountId from User set as "user" property at session scope

View UserAccountIdExtractor.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
package org.example;
 
import java.io.Serializable;
 
import org.springframework.social.web.connect.AccountIdExtractor;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.WebRequest;
 
// your own User class
import org.example.User;
 
/**
* extract accountId from User set as "user" property at session scope
*/
public class UserAccountIdExtractor implements AccountIdExtractor {
 
@Override
public Serializable extractAccountId(final WebRequest request) {
User user = (User) request.getAttribute("user", RequestAttributes.SCOPE_SESSION);
return user == null ? null : user.getId();
}
 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.