Renchon can't be deleted!
Cette révision appartient à :
Parent
a05883bc51
révision
ceb9e039f1
2 fichiers modifiés avec 5 ajouts et 1 suppressions
|
@ -218,12 +218,16 @@ func DeleteUser(w http.ResponseWriter, currentUser *model.User, id string) (int,
|
|||
if db.ORM.First(&user, id).RecordNotFound() {
|
||||
return http.StatusNotFound, errors.New("user not found")
|
||||
}
|
||||
if (user.ID == 0) {
|
||||
return http.StatusInternalServerError, errors.New("You can't delete that!")
|
||||
}
|
||||
if db.ORM.Delete(&user).Error != nil {
|
||||
return http.StatusInternalServerError, errors.New("user not deleted")
|
||||
}
|
||||
if userPermission.CurrentUserIdentical(currentUser, user.ID) {
|
||||
return ClearCookie(w)
|
||||
}
|
||||
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<tr>
|
||||
<td><a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}?edit">{{ .Username }}</a></td>
|
||||
<td><a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}?delete" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td>
|
||||
<td>{{if .ID > 0}}<a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}?delete" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a>{{end}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
|
|
Référencer dans un nouveau ticket