Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Disable editing user email #737

Merged
merged 1 commit into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/server/assets/users/_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<div class="form-label-group">
<input type="email" id="email" name="email" class="form-control{{if $user.ErrorsFor "email"}} is-invalid{{end}}"
value="{{$user.Email}}" placeholder="Email address" required />
value="{{$user.Email}}" placeholder="Email address" {{if $user.ID}}disabled{{else}}required{{end}} />
<label for="name">Email address</label>
{{if $user.ErrorsFor "email"}}
<div class="invalid-feedback">
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/user/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

func (c *Controller) HandleUpdate() http.Handler {
type FormData struct {
Email string `form:"email"`
Name string `form:"name"`
Admin bool `form:"admin"`
}
Expand Down Expand Up @@ -76,7 +75,6 @@ func (c *Controller) HandleUpdate() http.Handler {
err = controller.BindForm(w, r, &form)

// Build the user struct
user.Email = strings.TrimSpace(form.Email)
user.Name = strings.TrimSpace(form.Name)
if err != nil {
if terr, ok := err.(schema.MultiError); ok {
Expand Down