//------------------------------------------------------------------------- void _onUCenterLogin(UCenterResponseStatus status, AccountLoginResponse response, UCenterError error) { EbLog.Note("ClientSampleApp._onUCenterLogin() UCenterResult=" + status); if (error != null) { EbLog.Note("ErrorCode=" + error.ErrorCode); EbLog.Note("ErrorMessage=" + error.Message); } }
public AccountLoginResponse AccountLogin(AccountLoginRequest request) { AccountLoginResponse res = new AccountLoginResponse(); res = dao.AccountLogin(new AccountLoginRequest() { AccountName = request.AccountName, Password = Securities.SHA1(request.Password) }); return(res); }
//------------------------------------------------------------------------- void _onUCenterLogin(UCenterResponseStatus status, AccountLoginResponse response, UCenterError error) { string s = "ClientSampleApp._onUCenterLogin() UCenterResult=" + status; EbLog.Note(s); MbSample.Instance.ListInfo.Add(s); if (error != null) { EbLog.Note("ErrorCode=" + error.ErrorCode); EbLog.Note("ErrorMessage=" + error.Message); } }
public async Task <IActionResult> Login( [FromBody] AccountLoginRequest model, CancellationToken cancellationToken) { var result = await _signInManager.PasswordSignInAsync( model?.Login, model?.Password, false, false); if (!result.Succeeded) { return(Unauthorized(IdentityResult.Failed(new IdentityError { Code = "Unauthorized", Description = "Unauthorized" }))); } cancellationToken.ThrowIfCancellationRequested(); var user = await _userManager.FindByNameAsync(model?.Login); var token = await _jwtTokenFactory.CreateJwtToken(user.Id); var response = new AccountLoginResponse { Token = token, IdentityResult = IdentityResult.Success }; //TODO: вынести в отдельный мидлвар HttpContext.Response.Cookies.Append(".AspNetCore.Application.Token", token, new CookieOptions { HttpOnly = true, MaxAge = TimeSpan.FromDays(7) } ); HttpContext.Response.Cookies.Append("isAuth", "true", new CookieOptions { HttpOnly = false, MaxAge = TimeSpan.FromDays(7) }); return(Ok(response)); }
public AccountLoginResponse AccountLogin(AccountLoginRequest request) { AccountLoginResponse res = new AccountLoginResponse(); string strSP = SqlCommandStore.uspAccountLogin; try { using (SqlCommand cmd = new SqlCommand(strSP)) { cmd.Parameters.Add("AccountName", SqlDbType.NVarChar, 100).Value = request.AccountName; cmd.Parameters.Add("Password", SqlDbType.NVarChar, 100).Value = request.Password; cmd.Parameters.Add("@Return", SqlDbType.Int).Direction = ParameterDirection.ReturnValue; DataSet ds = DB.ExecuteSPDataSet(cmd); res.Code = (ReturnCode)Convert.ToInt32(cmd.Parameters["@Return"].Value); if (res.Code != ReturnCode.Success) { DB.RollBackTran(); return(res); } DB.CommitTran(); DataRow[] rows = new DataRow[ds.Tables[0].Rows.Count]; rows = new DataRow[ds.Tables[0].Rows.Count]; ds.Tables[0].Rows.CopyTo(rows, 0); res.Account = rows.Select(row => new AccountModel(row)).First(); // Return permisstiontypes //rows = new DataRow[ds.Tables[1].Rows.Count]; //ds.Tables[1].Rows.CopyTo(rows, 0); //res.PermissionTypes = rows.Select(row => row["RoleCode"] != DBNull.Value? (PermisstionType?)row["RoleCode"] : null).ToList(); return(res); }; } catch (Exception ex) { LogWriter.WriteLogException(ex); res.Code = ReturnCode.Fail; return(res); } }
//------------------------------------------------------------------------- void _onUCenterLogin(UCenterResponseStatus status, AccountLoginResponse response, UCenterError error) { EbLog.Note("ClientLogin._onUCenterLogin() Status=" + status); if (error != null) { EbLog.Note("ErrorCode=" + error.ErrorCode + " ErrorMsg=" + error.Message); } if (status == UCenterResponseStatus.Success) { CoApp.CoNetMonitor.AccId = response.AccountId; CoApp.CoNetMonitor.Acc = response.AccountName; CoApp.CoNetMonitor.Token = response.Token; //FloatMsgInfo f_info; //f_info.msg = "登陆成功"; //f_info.color = Color.green; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); // DataEye登陆 //CoApp.CoDataEye.login(Acc, AccId); ClientConfig cc = MbMain.Instance.ClientConfig; CoApp.CoNetMonitor.connectBase(cc.BaseIp, cc.BasePort); } else if (error != null) { if (error.ErrorCode == UCenterErrorCode.AccountNotExist) { //FloatMsgInfo f_info; //f_info.msg = "帐号不存在"; //f_info.color = Color.red; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); if (mGuestPlayerInfo != null) { //if(mGuestPlayerInfo.account_id==) mGuestPlayerInfo = null; PlayerPrefs.DeleteKey(mGuestPlayerKey); } } else if (error.ErrorCode == UCenterErrorCode.AccountLoginFailedPasswordNotMatch) { //FloatMsgInfo f_info; //f_info.msg = "帐号或密码错误"; //f_info.color = Color.red; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); } else if (error.ErrorCode == UCenterErrorCode.Failed) { //FloatMsgInfo f_info; //f_info.msg = "登陆失败"; //f_info.color = Color.red; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); } else { //FloatMsgInfo f_info; //f_info.msg = "其他登陆错误"; //f_info.color = Color.red; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); } } //UiHelper.DestroyWaiting(); }