-
Notifications
You must be signed in to change notification settings - Fork 658
/
doc.go
126 lines (103 loc) · 3.57 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package response
import "github.com/gin-gonic/gin"
type Response struct {
Response string
}
type ApiTokenResponse struct {
UserID string
Name string
Token string
ExpiresAt int64
CreatedAt int64
}
type Role string
type UserResponse struct {
ID string `bson:"_id,omitempty" json:"userID"`
Username string `bson:"username,omitempty" json:"username"`
Password string `bson:"password,omitempty" json:"password,omitempty"`
Email string `bson:"email,omitempty" json:"email,omitempty"`
Name string `bson:"name,omitempty" json:"name,omitempty"`
Role Role `bson:"role,omitempty" json:"role"`
DeactivatedAt *int64 `bson:"deactivated_at,omitempty" json:"deactivatedAt,omitempty"`
}
type CapabilitiesResponse struct {
Dex struct {
Enabled bool `json:"enabled"`
} `json:"dex"`
}
type MessageResponse struct {
Message string
}
type NewApiToken struct {
accessToken string
}
type LoginResponse struct {
accessToken string
projectID string
projectRole string
expiresIn string
}
// HTTPError example
func NewError(ctx *gin.Context, status int, err error) {
er := HTTPError{
Code: status,
Message: err.Error(),
}
ctx.JSON(status, er)
}
type HTTPError struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"status bad request"`
}
type ErrServerError struct {
Code int `json:"code" example:"500"`
Message string `json:"message" example:"The authorization server encountered an unexpected condition that prevented it from fulfilling the request"`
}
type ErrInvalidCredentials struct {
Code int `json:"code" example:"401"`
Message string `json:"message" example:"Invalid Credentials"`
}
type ErrInvalidRequest struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed"`
}
type ErrUnauthorized struct {
Code int `json:"code" example:"401"`
Message string `json:"message" example:"The user does not have requested authorization to access this resource"`
}
type ErrUserExists struct {
Code int `json:"code" example:"401"`
Message string `json:"message" example:"This username is already assigned to another user"`
}
type ErrUserNotFound struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"user does not exist"`
}
type ErrUserDeactivated struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"your account has been deactivated"`
}
type ErrStrictPasswordPolicyViolation struct {
Code int `json:"code" example:"401"`
Message string `json:"message" example:"Please ensure the password is 8 characters long and has 1 digit, 1 lowercase alphabet, 1 uppercase alphabet and 1 special character"`
}
type ErrEmptyProjectName struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"Project name can't be empty"`
}
type ErrInvalidRole struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"Role is invalid"`
}
type ErrProjectNotFound struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"This project does not exist"`
}
type ErrInvalidEmail struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"Email address is invalid"`
}
type ErrProjectNotFoundstruct struct {
Code int `json:"code" example:"400"`
Message string `json:"message" example:"project does not exist"`
}