CreateClient creates a client and returns the access token. swagger:operation POST /client client createClient Create a client. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: [
(ctx *gin.Context)
| 137 | // schema: |
| 138 | // $ref: "#/definitions/Error" |
| 139 | func (a *ClientAPI) CreateClient(ctx *gin.Context) { |
| 140 | clientParams := ClientParams{} |
| 141 | if err := ctx.Bind(&clientParams); err == nil { |
| 142 | client := model.Client{ |
| 143 | Name: clientParams.Name, |
| 144 | Token: auth.GenerateNotExistingToken(generateClientToken, a.clientExists), |
| 145 | UserID: auth.GetUserID(ctx), |
| 146 | } |
| 147 | |
| 148 | if success := successOrAbort(ctx, 500, a.DB.CreateClient(&client)); !success { |
| 149 | return |
| 150 | } |
| 151 | ctx.JSON(200, client) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // GetClients returns all clients a user has. |
| 156 | // swagger:operation GET /client client getClients |
nothing calls this directly
no test coverage detected