Made registration work
This commit is contained in:
@ -15,11 +15,9 @@ type UserLogin struct {
|
||||
// User holds information about an user
|
||||
type User struct {
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
|
||||
Name string `xorm:"varchar(250)" json:"name"`
|
||||
Username string `xorm:"varchar(250) not null unique" json:"username"`
|
||||
Password string `xorm:"varchar(250) not null" json:"password"`
|
||||
Email string `xorm:"varchar(250)" json:"email"`
|
||||
IsAdmin bool `xorm:"tinyint(1) not null" json:"isAdmin"`
|
||||
Created int64 `xorm:"created" json:"created"`
|
||||
Updated int64 `xorm:"updated" json:"updated"`
|
||||
}
|
||||
@ -84,7 +82,6 @@ func GetCurrentUser(c echo.Context) (user User, err error) {
|
||||
}
|
||||
user = User{
|
||||
ID: int64(userID),
|
||||
Name: claims["name"].(string),
|
||||
Email: claims["email"].(string),
|
||||
Username: claims["username"].(string),
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// CreateUser creates a new user and inserts it into the database
|
||||
func CreateUser(user User, doer *User) (newUser User, err error) {
|
||||
func CreateUser(user User) (newUser User, err error) {
|
||||
|
||||
newUser = user
|
||||
|
||||
@ -16,7 +16,7 @@ func CreateUser(user User, doer *User) (newUser User, err error) {
|
||||
|
||||
// Check if the user already existst with that username
|
||||
existingUser, exists, err := GetUser(User{Username: newUser.Username})
|
||||
if err != nil {
|
||||
if err != nil && !IsErrUserDoesNotExist(err){
|
||||
return User{}, err
|
||||
}
|
||||
if exists {
|
||||
@ -25,7 +25,7 @@ func CreateUser(user User, doer *User) (newUser User, err error) {
|
||||
|
||||
// Check if the user already existst with that email
|
||||
existingUser, exists, err = GetUser(User{Email: newUser.Email})
|
||||
if err != nil {
|
||||
if err != nil && !IsErrUserDoesNotExist(err) {
|
||||
return User{}, err
|
||||
}
|
||||
if exists {
|
||||
@ -60,7 +60,7 @@ func hashPassword(password string) (string, error) {
|
||||
}
|
||||
|
||||
// UpdateUser updates a user
|
||||
func UpdateUser(user User, doer *User) (updatedUser User, err error) {
|
||||
func UpdateUser(user User) (updatedUser User, err error) {
|
||||
|
||||
// Check if it exists
|
||||
theUser, exists, err := GetUserByID(user.ID)
|
||||
|
Reference in New Issue
Block a user