feat(user): 实现基础用户系统
- 实现用户手机验证码、密码登录功能,支持 JWT 认证 - 实现用户注册功能 - 实现jwt中获取用户信息
This commit is contained in:
@@ -10,7 +10,7 @@ info (
|
||||
type (
|
||||
sendSmsReq {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
actionType string `json:"actionType" validate:"required"`
|
||||
ActionType string `json:"actionType" validate:"required,oneof=loginCode registerCode QueryCode"`
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -24,9 +24,13 @@ service user {
|
||||
@handler register
|
||||
post /user/register (RegisterReq) returns (RegisterResp)
|
||||
|
||||
@doc "login"
|
||||
@handler login
|
||||
post /user/login (LoginReq) returns (LoginResp)
|
||||
@doc "mobile login"
|
||||
@handler mobileLogin
|
||||
post /user/mobileLogin (MobileLoginReq) returns (MobileLoginResp)
|
||||
|
||||
@doc "mobile code login"
|
||||
@handler mobileCodeLogin
|
||||
post /user/mobileCodeLogin (MobileCodeLoginReq) returns (MobileCodeLoginResp)
|
||||
}
|
||||
|
||||
//need login
|
||||
|
||||
@@ -8,14 +8,16 @@ info (
|
||||
)
|
||||
|
||||
type User {
|
||||
Id int64 `json:"id"`
|
||||
Mobile string `json:"mobile"`
|
||||
Id int64 `json:"id"`
|
||||
Mobile string `json:"mobile"`
|
||||
NickName string `json:"nickName"`
|
||||
}
|
||||
|
||||
type (
|
||||
RegisterReq {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Password string `json:"password" validate:"required,min=11,max=11,password"`
|
||||
Code string `json:"code" validate:"required"`
|
||||
}
|
||||
RegisterResp {
|
||||
AccessToken string `json:"accessToken"`
|
||||
@@ -25,11 +27,23 @@ type (
|
||||
)
|
||||
|
||||
type (
|
||||
LoginReq {
|
||||
Mobile string `json:"mobile"`
|
||||
Password string `json:"password"`
|
||||
MobileLoginReq {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
}
|
||||
LoginResp {
|
||||
MobileLoginResp {
|
||||
AccessToken string `json:"accessToken"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
MobileCodeLoginReq {
|
||||
Mobile string `json:"mobile"`
|
||||
Code string `json:"code" validate:"required"`
|
||||
}
|
||||
MobileCodeLoginResp {
|
||||
AccessToken string `json:"accessToken"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
|
||||
Reference in New Issue
Block a user