Documentation ¶
Index ¶
- func UserAuthenticateHandler(ctx *gin.Context)
- func UserChangePasswordHandler(ctx *gin.Context)
- func UserChangeRoleHandler(ctx *gin.Context)
- func UserGETHandler(ctx *gin.Context)
- func UserPUTHandler(ctx *gin.Context)
- func UserProfileHandler(ctx *gin.Context)
- func UserRegisterHandler(ctx *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UserAuthenticateHandler ¶
UserAuthenticateHandler handles an incoming request with three query parameters: username, password, and (optional) token.
Behavior: It authenticates the user account with the provided information and generates an authenticated token.
Response: A token in the body (for debugging) and as a cookie + An error message.
func UserChangePasswordHandler ¶
UserChangPasswordHandler handles an incoming PUT request of url /users/:id/password with three query parameters: newpassword and (optional) token, oldpassword.
Behavior: It updates password of the current profile. The subject is determined by token. The affected object is determined by the URL parameter. If the subject is higher role than the object, it doesn't need the oldpassword.
Response: An error message.
func UserChangeRoleHandler ¶
UserChangRoleHandler handles an incoming PUT request of url /users/:id/role with two query parameters: role and (optional) token.
Behavior: It updates role of the current profile. The subject is determined by token. The affected object is determined by the URL parameter.
Response: An error message.
func UserGETHandler ¶
UserGETHandler handles an incoming GET request of url /users/:id with one optional query parameter: token.
Behavior: It gets the profile of a user determined by URL parameter id. The subject is determined by the token.
Response: A profile + An error message.
func UserPUTHandler ¶
UserPUTHandler handles an incoming PUT request of url /users/:id with three optional query parameters: token, age, gender.
Behavior: It updates age and gender of the current profile. The subject is determined by token. The affected object is determined by the URL parameter. If the request doesn't provide age or gender, they will be set to null (a.k.a be deleted).
Response: An error message.
func UserProfileHandler ¶
UserProfileHandler handles an incoming request with one optional query parameter: token.
Behavior: It gets the profile of the user determined by the token.
Response: A profile + An error message.
func UserRegisterHandler ¶
UserRegisterHandler handles an incoming request with four query parameters: username, password, and (optional) token, role.
Behavior: It registers a user account with the provided information. If the role is a member, it doesn't need a subject to register; otherwise, the subject must be higher role.
Response: An error message.
Types ¶
This section is empty.