public async Task <ActionResult> Login(UserAuthentication model, string retUrl) { SigninStatus result = await SigninManager.SigninUserAsync(model.username, model.userpwd, model.custid); switch (result) { case SigninStatus.Success: IsAuthenticated = true; return(DoAuthentication(model.custid, model.username, retUrl)); break; case SigninStatus.Undefine: ViewBag.Error = "UserName or Password is not valid... Please Check"; break; } model.userpwd = string.Empty; return(View(model)); }
//サインイン public void SignIn() { StateText = "ログイン中・・・"; Enabled = false; Task.Run(new Action(() => { SigninStatus status = NicoNicoWrapperMain.Session.SignIn(MailAddress, Password); //サインイン失敗 if (status != SigninStatus.Success) { StateText = "ログインに失敗しました。"; Enabled = true; return; } Success = true; Messenger.Raise(new WindowActionMessage(WindowAction.Close, "WindowAction")); })); }
public ActionResult Signin(SigninViewModel viewModel, string redirectUrl) { if (ModelState.IsValid) { SigninStatus result = _accountBLL.Signin(viewModel.Username, viewModel.Password); switch (result) { case SigninStatus.Success: return(RedirectToLocal(redirectUrl)); case SigninStatus.Incorrect: ModelState.AddModelError("Password", "Username or password incorrect."); break; case SigninStatus.Failure: default: ModelState.AddModelError("Password", "Sign in failed. Please try again later."); break; } } return(View(viewModel)); }
/// <summary> /// Tries to sign the user in using their cookie. /// </summary> /// <param name="cookie">The users cookie to try and sign in with</param> /// <param name="secureCookie">The users secure cookie to try and sign in with</param> /// <param name="policy">This is either the poilicy to use when using identity OR the service name to use with SSO</param> /// <param name="siteID">The id of the site you want to sign them into</param> /// <returns>True if they are signed in, false if not</returns> public bool IsUserSignedInSecure(string cookie, string secureCookie, string policy, int siteID, string ipAddress, Guid BBCUid ) { _isSecureRequest = false; using (AuthenticateUser authenticatedUser = new AuthenticateUser(_signInSystem)) { if (_debugUserID.Length > 0) { authenticatedUser.DebugIdentityUserID(_debugUserID); } if (authenticatedUser.AuthenticateUserFromCookies(cookie, secureCookie, policy)) { _isSecureRequest = authenticatedUser.IsSecureRequest; // Check to see if the email is in the banned emails list BannedEmails emails = BannedEmails.GetObject(); string emailToCheck = authenticatedUser.Email; if (emailToCheck.Length == 0 || !emails.IsEmailInBannedFromSignInList(emailToCheck)) { // The users email is not in the banned list, get the rest of the details from the database if (CreateUserFromSignInUserID(authenticatedUser.SignInUserID, authenticatedUser.LegacyUserID, _signInSystem, siteID, authenticatedUser.LoginName, authenticatedUser.Email, authenticatedUser.UserName, ipAddress, BBCUid)) { _signedInStatus = SigninStatus.SignedInLoggedIn; // Check to see if we need to sync with the signin system details if (authenticatedUser.LastUpdatedDate > LastSynchronisedDate) { LastSynchronisedDate = authenticatedUser.LastUpdatedDate; SynchronizeUserSigninDetails(authenticatedUser.UserName, authenticatedUser.Email, authenticatedUser.LoginName); bool isKidsSite = _siteList.GetSiteOptionValueBool(siteID, "General", "IsKidsSite"); if (_siteList.GetSiteOptionValueBool(siteID, "CommentForum", "UseIDv4") && isKidsSite) { // Kids sites using iDv4 should set site suffix to the current displayname SynchroniseSiteSuffix(authenticatedUser.UserName); } else { // Do the normal checks for iDv3 sites if (_siteList.GetSiteOptionValueString(siteID, "User", "AutoGeneratedNames").Length > 0) { string siteSuffix = authenticatedUser.GetAutoGenNameFromSignInSystem(isKidsSite); SynchroniseSiteSuffix(siteSuffix); } } } return true; } } } // Check to see if the user was signed in, but not logged in if (authenticatedUser.IsSignedIn && !authenticatedUser.IsLoggedIn) { _signedInStatus = SigninStatus.SignedInNotLoggedIn; } } return false; }