diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-04-20 00:44:26 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-04-20 00:44:26 +0100 |
commit | f95b916652bf0cd02da0daedf6bfc647d4b32ca7 (patch) | |
tree | aed5f0df83ca306a274d5d0dfa1c63a34aeb5960 /server/main.go | |
parent | 3114920c0db2d2d4c5b342243204bc5ed7da9aa9 (diff) |
use a better function name
Diffstat (limited to 'server/main.go')
-rw-r--r-- | server/main.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/main.go b/server/main.go index 0125ca8..f90037b 100644 --- a/server/main.go +++ b/server/main.go @@ -112,7 +112,7 @@ func signHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, er } func loginHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, error) { - a.authsession = a.authprovider.StartSession(hex.EncodeToString(random(32))) + a.authsession = a.authprovider.StartSession(newState(32)) http.Redirect(w, r, a.authsession.AuthURL, http.StatusFound) return http.StatusFound, nil } @@ -170,12 +170,12 @@ func (ah appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } -func random(length int) []byte { - k := make([]byte, length) +func newState() string { + k := make([]byte, 32) if _, err := io.ReadFull(rand.Reader, k); err != nil { - return nil + return "unexpectedstring" } - return k + return hex.EncodeToString(k) } func main() { |