MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / Login

Method Login

internal/service/user.go:82–97  ·  view source on GitHub ↗

Login 用户登录

(ctx context.Context, username string, password string)

Source from the content-addressed store, hash-verified

80
81// Login 用户登录
82func (us *userService) Login(ctx context.Context, username string, password string) (domain.User, error) {
83 if username == "" || password == "" {
84 return domain.User{}, errors.New("用户名和密码不能为空")
85 }
86
87 u, err := us.repo.FindByUsername(ctx, username)
88 if err != nil {
89 return domain.User{}, err
90 }
91
92 if err := u.VerifyPassword(password); err != nil {
93 return domain.User{}, ErrInvalidUserOrPassword
94 }
95
96 return u, nil
97}
98
99// LoginBySMS 短信验证码登录
100func (us *userService) LoginBySMS(ctx context.Context, number string, code string) (domain.User, error) {

Callers

nothing calls this directly

Calls 2

VerifyPasswordMethod · 0.80
FindByUsernameMethod · 0.65

Tested by

no test coverage detected