private string SignInAdmin(LoginLogicModel model) { using (var context = new AASDBContext()) { var admin = context.Admins.SingleOrDefault(a => a.Username == model.Username); if (admin == null) { throw new LoginErrorException(); } if (string.IsNullOrWhiteSpace(admin.Salt)) { admin.Salt = PasswordHashProvider.GenerateSalt(); admin.Password = PasswordHashProvider.ComputePasswordHash(admin.Password.Trim(), admin.Salt); context.SaveChanges(); } var hash = PasswordHashProvider.ComputePasswordHash(model.Password, admin.Salt); if (admin.Password != hash) { throw new LoginErrorException(); } return(ComposeToken(model.Username, UserType.AdminUserType)); } }
private string SignInStudent(LoginLogicModel model) { using (var context = new AASDBContext()) { var student = context.Students.SingleOrDefault(a => a.Email == model.Username); if (student == null) { throw new LoginErrorException(); } if (string.IsNullOrWhiteSpace(student.Salt)) { student.Salt = PasswordHashProvider.GenerateSalt(); student.Password = PasswordHashProvider.ComputePasswordHash(student.Password.Trim(), student.Salt); context.SaveChanges(); } var hash = PasswordHashProvider.ComputePasswordHash(model.Password, student.Salt); if (student.Password != hash) { throw new LoginErrorException(); } return(ComposeToken(model.Username, UserType.StudentUserType)); } }
void ZHPayDidLogout() { // TODO: 回调:账号注销成功,此时需要将游戏退出,并切换到登录前画面 Debug.Log("ZHPay回调:注销成功"); LoginLogicModel loginLogic = LoginLogicModel.Inst; if (null != loginLogic) { if (loginLogic.NowState != LoginLogicModel.状态类型.登陆) { loginLogic.ChangeState(LoginLogicModel.状态类型.登陆); } return; } if (null != InSceneLogicModel.Inst) { InSceneLogicModel.Inst.BackToLoginScene(弹框按钮.确认); } LoginLocked = false; }
public async Task <ActionResult> ChangePassword(LoginLogicModel model) { return(View()); }
public IHttpActionResult Login([FromBody] LoginLogicModel model) { var result = Logic.SignIn(model); return(JsonEx(result)); }