summaryrefslogtreecommitdiff
path: root/api/auth/auth.go
diff options
context:
space:
mode:
authorElizabeth <elizabeth@simponic.xyz>2024-04-05 15:43:03 -0600
committerElizabeth <elizabeth@simponic.xyz>2024-04-05 15:43:03 -0600
commitae640a253edb5935380975fb07430e910a83b340 (patch)
tree62290bea86e150da13ccc46fb324670818df4a97 /api/auth/auth.go
parent94984aa4b01e96773b71325b5b27e6f64d9bd102 (diff)
downloadhatecomputers.club-ae640a253edb5935380975fb07430e910a83b340.tar.gz
hatecomputers.club-ae640a253edb5935380975fb07430e910a83b340.zip
add some auth test cases
Diffstat (limited to 'api/auth/auth.go')
-rw-r--r--api/auth/auth.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/api/auth/auth.go b/api/auth/auth.go
index 3c633cd..becce24 100644
--- a/api/auth/auth.go
+++ b/api/auth/auth.go
@@ -74,7 +74,6 @@ func InterceptOauthCodeContinuation(context *types.RequestContext, req *http.Req
reqContext := req.Context()
token, err := context.Args.OauthConfig.Exchange(reqContext, code, oauth2.SetAuthURLParam("code_verifier", verifierCookie.Value))
if err != nil {
- log.Println(err)
resp.WriteHeader(http.StatusInternalServerError)
return failure(context, req, resp)
}
@@ -195,12 +194,13 @@ func LogoutContinuation(context *types.RequestContext, req *http.Request, resp h
_ = database.DeleteSession(context.DBConn, sessionCookie.Value)
}
- http.Redirect(resp, req, "/", http.StatusFound)
http.SetCookie(resp, &http.Cookie{
Name: "session",
MaxAge: 0,
Value: "",
})
+ http.Redirect(resp, req, "/", http.StatusFound)
+
return success(context, req, resp)
}
}
@@ -225,10 +225,7 @@ func getOauthUser(dbConn *sql.DB, client *http.Client, uri string) (*database.Us
}
func createUserFromOauthResponse(response *http.Response) (*database.User, error) {
- user := &database.User{
- CreatedAt: time.Now(),
- }
-
+ user := &database.User{}
err := json.NewDecoder(response.Body).Decode(user)
defer response.Body.Close()