Allow updating birthdate, with admin report
This commit is contained in:
parent
7d3e04b869
commit
3543dd3e42
|
@ -77,12 +77,31 @@ func Settings() http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user isn't allowed to change it on their own, even if they edit the form to remove the readonly value.
|
// If the user changes their birthdate, notify the admin.
|
||||||
if !user.Birthdate.IsZero() && user.Birthdate.Format("2006-01-02") != dob {
|
if !user.Birthdate.IsZero() && user.Birthdate.Format("2006-01-02") != dob {
|
||||||
session.FlashError(w, r, "Please contact support if you want to change your birthdate.")
|
// Create an admin Feedback model.
|
||||||
} else {
|
fb := &models.Feedback{
|
||||||
user.Birthdate = birthdate
|
Intent: "report",
|
||||||
|
Subject: "report.dob",
|
||||||
|
UserID: user.ID,
|
||||||
|
TableName: "users",
|
||||||
|
TableID: user.ID,
|
||||||
|
Message: fmt.Sprintf(
|
||||||
|
"A user has modified their birthdate on their profile page!\n\n"+
|
||||||
|
"* Original: %s (age %d)\n* Updated: %s (age %d)",
|
||||||
|
user.Birthdate, utility.Age(user.Birthdate),
|
||||||
|
birthdate, utility.Age(birthdate),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the feedback.
|
||||||
|
if err := models.CreateFeedback(fb); err != nil {
|
||||||
|
log.Error("Couldn't save feedback from user updating their DOB: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around DST issues: set the hour to noon.
|
||||||
|
user.Birthdate = birthdate.Add(12 * time.Hour)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set profile attributes.
|
// Set profile attributes.
|
||||||
|
|
|
@ -73,12 +73,12 @@
|
||||||
id="dob"
|
id="dob"
|
||||||
name="dob"
|
name="dob"
|
||||||
value="{{if not $User.Birthdate.IsZero}}{{$User.Birthdate.Format "2006-01-02"}}{{end}}"
|
value="{{if not $User.Birthdate.IsZero}}{{$User.Birthdate.Format "2006-01-02"}}{{end}}"
|
||||||
required
|
required>
|
||||||
{{if not $User.Birthdate.IsZero}}readonly{{end}}>
|
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Used to show your age on your profile.
|
Used to show your age on your profile.
|
||||||
{{if not $User.Birthdate.IsZero}}
|
{{if not $User.Birthdate.IsZero}}
|
||||||
If you entered a wrong birthdate, <a href="/contact">contact</a> support to change it.
|
If you entered a wrong birthdate, you can change it here. Note that all birthdate
|
||||||
|
changes will notify the admin, so don't mess around or behave dishonestly.
|
||||||
{{end}}
|
{{end}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user