private async Task DeleteForm_Submit() { if (!(await users.AuthenticateAsync(CurrentUser.Username, _deleteModel.Password)).Success) { _deleteValidator.Error(nameof(_deleteModel.Password), "Incorrect password."); return; } await users.DeleteAsync(CurrentUser.Id); navigation.NavigateToLogout(); }
private async Task UsernameForm_Submit() { string username = _usernameModel.Username; if (await users.AnyUsernameAsync(username)) { _usernameValidator.Error(nameof(_usernameModel.Username), "That username is already in use."); return; } await users.UpdateUsernameAsync(CurrentUser.Id, _usernameModel.Username); navigation.NavigateToRefresh(); }
private async Task AdminPasswordForm_Submit() { if (!(await users.AuthenticateAsync(_context.User.Username(), _passwordForm.CurrentPassword)).Success) { _serverSideValidator.Error(nameof(_passwordForm.CurrentPassword), "Admin password was incorrect."); return; } await users.UpdatePasswordAysnc(_user.Id, _passwordForm.NewPassword); alertState.Add(new AlertModel { Context = BootstrapContext.Success, ChildContent = alertContent }); _passwordForm = new ChangePasswordViewModel(); }
private async Task EditForm_Submit() { if (_form.Version < _download.Version) { _serverSideValidator.Error(nameof(_form.Version), "New version must be greater than or equal to current version."); return; } _download.Title = _form.Title; _download.ShortDescription = _form.ShortDescription; _download.LongDescription = _form.LongDescription; _download.Version = _form.Version; _download.Visibility = _form.Visibility; await downloads.UpdateAsync(Id, _download); editDownloadState.Title = _form.Title; }
private async Task PasswordForm_Submit() { if (!(await users.AuthenticateAsync(CurrentUser.Username, _passwordModel.CurrentPassword)).Success) { _passwordValidator.Error(nameof(_passwordModel.CurrentPassword), "Incorrect current password."); return; } await users.UpdatePasswordAysnc(CurrentUser.Id, _passwordModel.NewPassword); _passwordModel = new ChangePasswordViewModel(); alertState.Add(new AlertModel { Context = BootstrapContext.Success, ChildContent = _alertContent }); }
private async Task UrlForm_Submit() { if (string.IsNullOrWhiteSpace(_urlModel.VanityUrl)) { await users.UpdateVanityUrlAsync(CurrentUser.Id, null); CurrentUser.VanityUrl = null; return; } if (await users.AnyVanityUrlAsync(_urlModel.VanityUrl)) { _urlValidator.Error(nameof(_urlModel), "That URL is unavailable."); return; } await users.UpdateVanityUrlAsync(CurrentUser.Id, _urlModel.VanityUrl); CurrentUser.VanityUrl = _urlModel.VanityUrl; _urlModel.VanityUrl = ""; }