Adding models, DB access, signup, login
* Created Base, Auth, User and Admin models * Added skeleton API structure containing: User signup, User & Admin login, authorized zones, ping tests * Simple user signup functional * Skeleton user login functional, no means to verify as of yet * Added POSTMAN file
This commit is contained in:
24
models/user.go
Normal file
24
models/user.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/yxzzy-wtf/gin-gonic-prepack/database"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Auth
|
||||
Email string `gorm:"unique"`
|
||||
}
|
||||
|
||||
func (u *User) GetJwt() (string, int) {
|
||||
return "", 0
|
||||
}
|
||||
|
||||
func (u *User) ByEmail(email string) error {
|
||||
if err := database.Db.Where("email = ?", email).First(&u).Error; err != nil {
|
||||
return errors.New("not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user