mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: team access control
This commit is contained in:
@@ -54,7 +54,21 @@ func login(c *fiber.Ctx) error {
|
||||
|
||||
func getUser(c *fiber.Ctx) error {
|
||||
user := utils.GetUser(c)
|
||||
return c.JSON(user)
|
||||
teams := []TeamWithRole{}
|
||||
|
||||
for _, item := range user.Teams {
|
||||
teams = append(teams, TeamWithRole{
|
||||
ID: item.TeamID,
|
||||
Name: item.Team.Name,
|
||||
Icon: item.Team.Icon,
|
||||
Role: item.Role,
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(&GetUserResult{
|
||||
AuthUser: *user,
|
||||
Teams: teams,
|
||||
})
|
||||
}
|
||||
|
||||
func logout(c *fiber.Ctx) error {
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
package auth
|
||||
|
||||
import "rul.sh/vaulterm/middleware"
|
||||
|
||||
type LoginSchema struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type TeamWithRole struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
type GetUserResult struct {
|
||||
middleware.AuthUser
|
||||
Teams []TeamWithRole `json:"teams"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user