Beispiel #1
0
// Save - insert session in DB
func (session *Session) Save() error {
	session.Token = core.GenerateToken()

	if _, err := orm.Insert(session); err != nil {
		return err
	}

	return nil
}
Beispiel #2
0
// Save - insert session in DB
func (user *User) Save() error {
	hashedPassword, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost)

	if err != nil {
		return err
	}

	user.Password = string(hashedPassword)

	if _, err := orm.Insert(user); err != nil {
		return err
	}

	id, err := orm.LastInsertedID(user)

	if err != nil {
		return err
	}

	user.ID = id

	return nil
}