auth
2014-08-13
Parent:fb2fd59f9930
auth/info.go
Add a bunch of TODOs. Let's be realistic about what still needs to be done and tag it appropriately.
1 package auth
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.IsExpired() {
27 // TODO: return error
28 return
29 }
31 accessData.ExpiresIn = int32(accessData.CreatedAt.Add(time.Duration(accessData.ExpiresIn)*time.Second).Sub(time.Now()) / time.Second)
32 // TODO: write accessData
33 }