ClrPlus.Powershell.Core.Service.RestService.OnAuthenticated C# (CSharp) Метод

OnAuthenticated() статический приватный Метод

static private OnAuthenticated ( IServiceBase authService, IAuthSession session, IOAuthTokens tokens, string>.Dictionary authInfo, System.TimeSpan SessionExpiry ) : void
authService IServiceBase
session IAuthSession
tokens IOAuthTokens
authInfo string>.Dictionary
SessionExpiry System.TimeSpan
Результат 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);
        }

Usage Example

Пример #1
0
 public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary <string, string> authInfo)
 {
     RestService.OnAuthenticated(authService, session, tokens, authInfo, SessionExpiry);
 }