|
|
@ -41,19 +41,17 @@ func (tokens Tokens) Post(request *http.Request) (int, interface{}, http.Header) |
|
|
|
auth := request.Form.Get("a") |
|
|
|
auth := request.Form.Get("a") |
|
|
|
|
|
|
|
|
|
|
|
if len(auth) > 100 { |
|
|
|
if len(auth) > 100 { |
|
|
|
return 413, NewApiError("auth_too_large", "Auth too large"), nil |
|
|
|
return 413, NewApiError("auth_too_large", "Auth too large"), http.Header{"Content-Type": {"application/json"}} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
valid := tokens.provider(strings.ToLower(auth)) |
|
|
|
valid := tokens.provider(strings.ToLower(auth)) |
|
|
|
response := &Token{Token: valid} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if valid != "" { |
|
|
|
if valid != "" { |
|
|
|
log.Printf("Good incoming token request: %s\n", auth) |
|
|
|
log.Printf("Good incoming token request: %s\n", auth) |
|
|
|
response.Success = true |
|
|
|
return 200, &Token{Token: valid, Success: true}, http.Header{"Content-Type": {"application/json"}} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.Printf("Wrong incoming token request: %s\n", auth) |
|
|
|
log.Printf("Wrong incoming token request: %s\n", auth) |
|
|
|
|
|
|
|
return 403, NewApiError("invalid_token", "Invalid token"), http.Header{"Content-Type": {"application/json"}} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 200, response, http.Header{"Content-Type": {"application/json"}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|