44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package user
|
|
|
|
import (
|
|
"jannex/admin-dashboard-backend/modules/database"
|
|
"jannex/admin-dashboard-backend/modules/structs"
|
|
"jannex/admin-dashboard-backend/socketclients"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func GetUserProfile(c *fiber.Ctx) error {
|
|
// swagger:operation GET /user/profile user userProfile
|
|
// ---
|
|
// summary: Get user profile
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: X-Api-Key
|
|
// in: header
|
|
// description: You can create a new api key in your user profile
|
|
// responses:
|
|
// '200':
|
|
// description: User profile
|
|
// schema:
|
|
// "$ref": "#/definitions/UserProfileResponse"
|
|
// '401':
|
|
// description: No permissions
|
|
// '500':
|
|
// description: Failed to get user profile
|
|
|
|
var user structs.User
|
|
userId := c.Locals("userId").(string)
|
|
|
|
database.DB.First(&user, "id = ?", userId)
|
|
|
|
return c.JSON(structs.UserProfileResponse{
|
|
Email: user.Email,
|
|
Sessions: socketclients.GetUserSessions(userId),
|
|
ApiKeys: socketclients.GetUserApiKeys(userId),
|
|
})
|
|
}
|