示例#1
0
 static AuthenticationResult ViewToResult(UserId id, LoginView view)
 {
     var auth = new AuthInfo(id, view.Token);
     var result =
         new AuthenticationResult(new SessionIdentity(id, view.Security, view.Display, auth.ToCookieString(),
             view.Permissions, view.Token));
     return result;
 }
示例#2
0
 void ReportLoginSuccess(UserId id, LoginView view)
 {
     // we are good. Now, report success, if needed, to update all the views
     var time = DateTime.UtcNow;
     string host = HttpContext.Current.Request.UserHostAddress;
     if ((view.LastLoginUtc == DateTime.MinValue) || ((time - view.LastLoginUtc) > view.LoginTrackingThreshold))
     {
         _webEndpoint.SendOne(new ReportUserLoginSuccess(id, time, host));
     }
 }
示例#3
0
        static string ComposeLockoutMessage(LoginView view)
        {
            var lockoutTill = view.LockedOutTillUtc;

            var message = view.LockoutMessage;
            var current = DateTime.UtcNow;
            if (lockoutTill.Year - current.Year > 1)
            {
                // this is a really long lockout
                return message;
            }
            var diff = lockoutTill - current;
            string timer;
            if (diff.TotalHours > 1)
            {
                timer = string.Format("Account locked out till {0:yyyy-MM-dd HH:mm}", lockoutTill);
            }
            else
            {
                timer = string.Format("Account locked out for {0} minutes", Math.Ceiling(diff.TotalMinutes));
            }

            if (!string.IsNullOrEmpty(message))
                timer += ". " + message;
            return timer;
        }