// Package auth provides authentication and authorization functionality. package auth import ( "errors" "github.com/runningwater/gohub/app/models/user" ) // Attemp login func Attemp(email, password string) (user.User, error) { userModel := user.GetByMulti(email) if userModel.ID == 0 { return user.User{}, errors.New("账号不存在") } if !userModel.ComparePassword(password) { return user.User{}, errors.New("密码错误") } return userModel, nil } // LoginByPhone 登陆指定用户 func LoginByPhone(phone string) (user.User, error) { userModel := user.GetByPhone(phone) if userModel.ID == 0 { return user.User{}, errors.New("账号不存在") } return userModel, nil }