added user sign up process
parent
53892ab13f
commit
67e4be9fd5
|
@ -40,4 +40,20 @@ var (
|
||||||
"created_at"},
|
"created_at"},
|
||||||
PartKey: []string{"id"},
|
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 {
|
type UsersResponse struct {
|
||||||
Users []User
|
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 {
|
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:
|
// consumes:
|
||||||
// - application/json
|
// - application/json
|
||||||
// produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
// responses:
|
// responses:
|
||||||
// '200':
|
// '200':
|
||||||
// description: List of users
|
// description: List of user sign up processes
|
||||||
// schema:
|
// schema:
|
||||||
// "$ref": "#/definitions/UsersResponse"
|
// "$ref": "#/definitions/UsersResponse"
|
||||||
// '500':
|
// '500':
|
||||||
// description: Internal server error
|
// 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 {
|
if err := q.SelectRelease(&userSignUpProcesses); err != nil {
|
||||||
logrus.Errorln("Failed to get users, err:", err)
|
logrus.Errorln("Failed to get user sign up processes, err:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var nUsers []structs.User
|
return c.JSON(structs.UserSignUpProcessesResponse{UserSignUpProcesses: userSignUpProcesses})
|
||||||
|
|
||||||
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})
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ func SetupRoutes(app *fiber.App) {
|
||||||
|
|
||||||
us := v1.Group("/users")
|
us := v1.Group("/users")
|
||||||
us.Get("/", ApiKeyValidation, users.GetAllUsers)
|
us.Get("/", ApiKeyValidation, users.GetAllUsers)
|
||||||
|
us.Get("/usersignupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses)
|
||||||
|
|
||||||
wss := v1.Group("/wssessions")
|
wss := v1.Group("/wssessions")
|
||||||
wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)
|
wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)
|
||||||
|
|
Loading…
Reference in New Issue