public async Task <ActionResult <RequestResult> > Login([FromBody] LoginRequestParameter parameter) { if (!ModelState.IsValid) { return(RequestResult.CreateErrorResult("")); } var now = DateTime.Now; var userInfo = await service.GetUserByLoginInfo(parameter.LoginId, parameter.Password); if (userInfo == null) { return(RequestResult.CreateErrorResult("ユーザーIDまたはパスワードが間違っています。")); } var claims = new List <Claim> { new Claim(ClaimTypes.Name, userInfo.UserNo.ToString()) }; ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "login")); //一度ログアウト・セッションのクリアを行う。 await HttpContext.SignOutAsync(Startup.AuthScheme); HttpContext.Session.Clear(); //ログイン処理 await HttpContext.SignInAsync(Startup.AuthScheme, principal, new AuthenticationProperties() { //IsPersistent = true }); //セッションにユーザ情報をセットする。 var context = new LoginUserContext(userInfo); HttpContext.Session.Set <LoginUserContext>(LoginUserContext.InSessionKey, context); //セッションにアプリケーション情報をセットする。 var appInfo = await appService.GetApplicationInfo(); var appContext = new ApplicationContext(appInfo); HttpContext.Session.Set <ApplicationContext>(ApplicationContext.InSessionKey, appContext); string redirectUrl = ""; //ReturnUrlはjavascript側でurlから取得して設定している。 if (!string.IsNullOrEmpty(parameter.ReturnUrl) && Url.IsLocalUrl(parameter.ReturnUrl)) { redirectUrl = new PathString(parameter.ReturnUrl); } return(RequestResult.CreateSuccessResult(new { RedirectUrl = redirectUrl })); }
public async Task <LoginResult> LoginAsync(string username, string password, string verificationCode) { LoginResult loginResult = new LoginResult(); LoginRequestParameter loginParams = new LoginRequestParameter(); loginParams.Username = username; loginParams.Password = password; loginParams.VerificationCode = verificationCode; loginResult = await _baseService.PostAsync <LoginResult>("/Account/Login/", loginParams); return(loginResult); }
public void StartInitialize() { LoginRequestParameter parameter = new LoginRequestParameter(); if (CommonHelper.PlatformType == PlatformType.Nd) { parameter.NdID = NdCenter.Instace.NdID; } else if (CommonHelper.PlatformType == PlatformType.iOS) { parameter.AccountID = iOSCenter.Instance.AccountID; } CommunicationUtility.Instance.GetUserData(this, "ReceivedUserData", false, parameter); this.StartCoroutine("InitialUserData"); }
public void GetUserData(Component receiver, string methodName, bool isListenOnce, LoginRequestParameter parameter) { this.CommunicateWithServer(receiver, methodName, isListenOnce, parameter.GetHashtableFromParameter(), ClientCommandConsts.PLAYER_LOGIN_COMMAND, ServerCommandConsts.PLAYER_LOGIN_SUCCESS); }