static private OnAuthenticated ( IServiceBase authService, IAuthSession session, IOAuthTokens tokens, string>.Dictionary |
||
authService | IServiceBase | |
session | IAuthSession | |
tokens | IOAuthTokens | |
authInfo | string>.Dictionary | |
SessionExpiry | System.TimeSpan | |
return | void |
internal static void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo, TimeSpan? SessionExpiry)
{
var user = GetUserRule(session.UserAuthName);
if (user == null) {
return;
}
session.IsAuthenticated = true;
//Fill the IAuthSession with data which you want to retrieve in the app eg:
session.FirstName = user.HasProperty("firstname") ? user["firstname"].Value : "";
session.LastName = user.HasProperty("lastname") ? user["lastname"].Value : "";
session.Roles = new XList<string>();
// check to see if user has an unsalted password
var storedPassword = user["password"].Value;
if (storedPassword.Length != 32) {
session.Roles.Add("password_must_be_changed");
}
if (user.HasProperty("roles")) {
session.Roles.AddRange(user["roles"].Values);
}
//Important: You need to save the session!
authService.SaveSession(session, SessionExpiry);
}
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary <string, string> authInfo) { RestService.OnAuthenticated(authService, session, tokens, authInfo, SessionExpiry); }