added user sign up process
parent
53892ab13f
commit
67e4be9fd5
|
@ -40,4 +40,20 @@ var (
|
|||
"created_at"},
|
||||
PartKey: []string{"id"},
|
||||
})
|
||||
|
||||
UserSignUpProcess = table.New(table.Metadata{
|
||||
Name: "user_sign_up_process",
|
||||
Columns: []string{
|
||||
"x_token",
|
||||
"email",
|
||||
"user_agent",
|
||||
"ip",
|
||||
"email_verify_code",
|
||||
"email_verified",
|
||||
"last_email_resend",
|
||||
"created_at",
|
||||
"expires_at",
|
||||
},
|
||||
PartKey: []string{"x_token"},
|
||||
})
|
||||
)
|
||||
|
|
|
@ -50,3 +50,20 @@ func (u *UserPublicKeys) UnmarshalUDT(name string, info gocql.TypeInfo, data []b
|
|||
type UsersResponse struct {
|
||||
Users []User
|
||||
}
|
||||
|
||||
type UserSignUpProcess struct {
|
||||
XToken string
|
||||
Email string
|
||||
UserAgent string
|
||||
Ip string
|
||||
EmailVerifyCode string
|
||||
EmailVerified bool
|
||||
LastEmailResend int64
|
||||
CreatedAt int64
|
||||
ExpiresAt int64
|
||||
}
|
||||
|
||||
// swagger:model UserSignUpProcessesResponse
|
||||
type UserSignUpProcessesResponse struct {
|
||||
UserSignUpProcesses []UserSignUpProcess
|
||||
}
|
||||
|
|
|
@ -44,37 +44,28 @@ func GetAllUsers(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
func GetAllUserSignUpProcesses(c *fiber.Ctx) error {
|
||||
// swagger:operation GET /users users usersGetAllUsers
|
||||
// swagger:operation GET /users/usersignupprocesses users usersGetAllUserSignUpProcesses
|
||||
// ---
|
||||
// summary: List of users
|
||||
// summary: List of user sign up processes
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// responses:
|
||||
// '200':
|
||||
// description: List of users
|
||||
// description: List of user sign up processes
|
||||
// schema:
|
||||
// "$ref": "#/definitions/UsersResponse"
|
||||
// '500':
|
||||
// description: Internal server error
|
||||
|
||||
var users []structs.User
|
||||
var userSignUpProcesses []structs.UserSignUpProcess
|
||||
|
||||
q := scylladb.Session.Query(scylladb.Users.SelectAll())
|
||||
q := scylladb.Session.Query(scylladb.UserSignUpProcess.SelectAll())
|
||||
|
||||
if err := q.SelectRelease(&users); err != nil {
|
||||
logrus.Errorln("Failed to get users, err:", err)
|
||||
if err := q.SelectRelease(&userSignUpProcesses); err != nil {
|
||||
logrus.Errorln("Failed to get user sign up processes, err:", err)
|
||||
}
|
||||
|
||||
var nUsers []structs.User
|
||||
|
||||
if len(users) > 0 { // remove password value from result
|
||||
for _, user := range users {
|
||||
user.Password = ""
|
||||
nUsers = append(nUsers, user)
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(structs.UsersResponse{Users: nUsers})
|
||||
return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses})
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ func SetupRoutes(app *fiber.App) {
|
|||
|
||||
us := v1.Group("/users")
|
||||
us.Get("/", ApiKeyValidation, users.GetAllUsers)
|
||||
us.Get("/usersignupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses)
|
||||
|
||||
wss := v1.Group("/wssessions")
|
||||
wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)
|
||||
|
|
Loading…
Reference in New Issue