public OutputData Update(IInputData input, object instance) { BasePasswordData passwd = instance.Convert <BasePasswordData>(); InternalAccount account = new InternalAccount(passwd.UserId, passwd.Password); account.Update(); return(OutputData.CreateToolkitObject(KeyData.Empty)); }
public OutputData Update(IInputData input, object instance) { BasePasswordData passwd = instance.Convert <BasePasswordData>(); using (EmptyDbDataSource source = new EmptyDbDataSource()) using (UserResolver resolver = new UserResolver(source)) { return(ChangePasswd(resolver, passwd)); } }
protected override OutputData ChangePasswd(UserResolver resolver, BasePasswordData passwd) { PasswordData password = passwd.Convert<PasswordData>(); bool success = resolver.ChangePassword(passwd.UserId, passwd.GetNewPassword("PasswordData"), password.OldPassword); if (success) return OutputData.CreateToolkitObject(resolver.CreateKeyData()); else { const string errorMsg = "原密码不匹配"; FieldErrorInfo field = new FieldErrorInfo("PasswordData", "OldPassword", errorMsg); throw new WebPostException(errorMsg, field); } }
protected override OutputData ChangePasswd(UserResolver resolver, BasePasswordData passwd) { PasswordData password = passwd.Convert <PasswordData>(); bool success = resolver.ChangePassword(passwd.UserId, passwd.GetNewPassword("PasswordData"), password.OldPassword); if (success) { return(OutputData.CreateToolkitObject(resolver.CreateKeyData())); } else { const string errorMsg = "原密码不匹配"; FieldErrorInfo field = new FieldErrorInfo("PasswordData", "OldPassword", errorMsg); throw new WebPostException(errorMsg, field); } }
protected override OutputData ChangePasswd(UserResolver resolver, BasePasswordData passwd) { resolver.ChangePassword(passwd.UserId, passwd.GetNewPassword("PasswordData"), null); return OutputData.CreateToolkitObject(resolver.CreateKeyData()); }
protected abstract OutputData ChangePasswd(UserResolver resolver, BasePasswordData passwd);
protected override OutputData ChangePasswd(UserResolver resolver, BasePasswordData passwd) { resolver.ChangePassword(passwd.UserId, passwd.GetNewPassword("PasswordData"), null); return(OutputData.CreateToolkitObject(resolver.CreateKeyData())); }