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.
1 package oauth2
3 import (
4 "net/http"
5 "time"
6 )
8 // HandleInfoRequest is an http.HandlerFunc for server information
9 // NOT an RFC specification.
10 func HandleInfoRequest(w http.ResponseWriter, r *http.Request, ctx Context) {
11 r.ParseForm()
13 code := r.Form.Get("code")
15 if code == "" {
16 // TODO: return error
17 return
18 }
20 // load access data
21 accessData, err := ctx.Tokens.GetAccess(code)
22 if err != nil {
23 // TODO: return error
24 return
25 }
26 if accessData.Client.RedirectURI == "" {
27 // TODO: return error
28 return
29 }
30 if accessData.IsExpired() {
31 // TODO: return error
32 return
33 }
35 accessData.ExpiresIn = int32(accessData.CreatedAt.Add(time.Duration(accessData.ExpiresIn)*time.Second).Sub(time.Now()) / time.Second)
36 // TODO: write accessData
37 }