auth
auth/info.go
Continue our descent to horribleness. Remove all the nonsense about "extensibility" and "clean separation of concerns", instead hardcoding connections to decisions. Remove all those "test" things that stopped passing.
| paddy@0 | 1 package oauth2 |
| paddy@0 | 2 |
| paddy@1 | 3 import ( |
| paddy@1 | 4 "net/http" |
| paddy@1 | 5 "time" |
| paddy@1 | 6 ) |
| paddy@0 | 7 |
| paddy@0 | 8 // HandleInfoRequest is an http.HandlerFunc for server information |
| paddy@0 | 9 // NOT an RFC specification. |
| paddy@0 | 10 func HandleInfoRequest(w http.ResponseWriter, r *http.Request, ctx Context) { |
| paddy@0 | 11 r.ParseForm() |
| paddy@0 | 12 |
| paddy@1 | 13 code := r.Form.Get("code") |
| paddy@0 | 14 |
| paddy@1 | 15 if code == "" { |
| paddy@0 | 16 // TODO: return error |
| paddy@0 | 17 return |
| paddy@0 | 18 } |
| paddy@0 | 19 |
| paddy@0 | 20 // load access data |
| paddy@1 | 21 accessData, err := ctx.Tokens.GetAccess(code) |
| paddy@0 | 22 if err != nil { |
| paddy@0 | 23 // TODO: return error |
| paddy@0 | 24 return |
| paddy@0 | 25 } |
| paddy@1 | 26 if accessData.Client.RedirectURI == "" { |
| paddy@0 | 27 // TODO: return error |
| paddy@0 | 28 return |
| paddy@0 | 29 } |
| paddy@1 | 30 if accessData.IsExpired() { |
| paddy@0 | 31 // TODO: return error |
| paddy@0 | 32 return |
| paddy@0 | 33 } |
| paddy@1 | 34 |
| paddy@1 | 35 accessData.ExpiresIn = int32(accessData.CreatedAt.Add(time.Duration(accessData.ExpiresIn)*time.Second).Sub(time.Now()) / time.Second) |
| paddy@1 | 36 // TODO: write accessData |
| paddy@0 | 37 } |