New User status (#957)
Status for scrapped user They can't log in and an explicit error message is shown when they try explaining that they need to contact the moderators They are displayed as simple members on the front-end however
Cette révision appartient à :
Parent
fdce17d52c
révision
752544a52c
5 fichiers modifiés avec 17 ajouts et 0 suppressions
|
@ -17,6 +17,8 @@ const (
|
|||
UserStatusTrusted = 1
|
||||
// UserStatusModerator : Int for User status moderator
|
||||
UserStatusModerator = 2
|
||||
// UserStatusScrapped : Int for User status scrapped
|
||||
UserStatusScrapped = 3
|
||||
)
|
||||
|
||||
// User model
|
||||
|
@ -93,6 +95,11 @@ func (u *User) IsModerator() bool {
|
|||
return u.Status == UserStatusModerator
|
||||
}
|
||||
|
||||
// IsScrapped : Return true if user is a scrapped user
|
||||
func (u *User) IsScrapped() bool {
|
||||
return u.Status == UserStatusScrapped
|
||||
}
|
||||
|
||||
// GetUnreadNotifications : Get unread notifications from a user
|
||||
func (u *User) GetUnreadNotifications() int {
|
||||
if u.UnreadNotifications == 0 {
|
||||
|
|
|
@ -106,6 +106,9 @@ func SetCookieHandler(w http.ResponseWriter, r *http.Request, email string, pass
|
|||
if user.IsBanned() {
|
||||
return http.StatusUnauthorized, errors.New("Account banned")
|
||||
}
|
||||
if user.IsScrapped() {
|
||||
return http.StatusUnauthorized, errors.New("Account need activation from Moderators, please contact us")
|
||||
}
|
||||
|
||||
maxAge := getMaxAge()
|
||||
validUntil := timeHelper.FewDurationLater(time.Duration(maxAge) * time.Second)
|
||||
|
|
|
@ -36,6 +36,8 @@ func GetRole(user *model.User) string {
|
|||
return "Banned"
|
||||
case model.UserStatusMember:
|
||||
return "Member"
|
||||
case model.UserStatusScrapped:
|
||||
return "Member"
|
||||
case model.UserStatusTrusted:
|
||||
return "Trusted Member"
|
||||
case model.UserStatusModerator:
|
||||
|
|
|
@ -173,6 +173,7 @@
|
|||
{{ if eq .Status 2 }} <!-- just so that it shows correctly -->
|
||||
<option value="2" selected>{{ call $.T "moderator"}}</option>
|
||||
{{end}}
|
||||
<option value="3" {{ if eq .Status 3 }}selected{{end}}>{{ call $.T "scrapped_user"}}</option>
|
||||
</select>
|
||||
{{ range (index $.FormErrors "status")}}
|
||||
<p class="error-text">{{ . }}</p>
|
||||
|
|
|
@ -551,6 +551,10 @@
|
|||
"id": "trusted_member",
|
||||
"translation": "Trusted member"
|
||||
},
|
||||
{
|
||||
"id": "scrapped_user",
|
||||
"translation": "Scrapped user"
|
||||
},
|
||||
{
|
||||
"id": "moderator",
|
||||
"translation": "Moderator"
|
||||
|
|
Référencer dans un nouveau ticket