email 唯一
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
type User struct {
|
||||
ID int `json:"id" gorm:"primary_key"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Email string `json:"email" gorm:"unique;not null"`
|
||||
Password string `json:"-"`
|
||||
Slat string `json:"-"`
|
||||
Admin bool `json:"admin"`
|
||||
|
@@ -63,7 +63,7 @@ func SessionsPost(w http.ResponseWriter, r *http.Request) {
|
||||
// 使用Email獲取用戶
|
||||
var user models.User
|
||||
if err := configs.ORMDB().Where("email = ?", form.Email).First(&user).Error; err != nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("404 - User Not Found"))
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user