Skip to content
Snippets Groups Projects
Commit a82d4155 authored by Jonas Kjærandsen's avatar Jonas Kjærandsen
Browse files

Fixed feide logout.

parent 7b00fea7
No related branches found
No related tags found
1 merge request!2Merge react-branch into main.
......@@ -2,11 +2,10 @@ package auth
import (
"crypto/sha256"
logging "dcsg2900-threattotal/logs"
"dcsg2900-threattotal/utils"
"dcsg2900-threattotal/logs"
"encoding/json"
"fmt"
"net/http"
"time"
)
......@@ -172,27 +171,12 @@ func tokenToHash(code string) (hash string) {
}
func Logout(hash string) bool {
// Get the login details from the database
userToken, err := getAuth(hash)
if !err {
return false
}
// Delete the database item
_, error := utils.Conn.Do("DEL", hash)
_, error := utils.Conn.Do("DEL", "user:"+hash)
if error != nil {
fmt.Println("Error removing data from redis:" + error.Error())
logging.Logerror(error, "Error removing data from redis Auth.go:")
return false
}
// Send a logout request to feide
resp, error := http.Get("https://auth.dataporten.no/openid/endsession?id_token_hint=" + userToken)
if error != nil {
fmt.Println("Error logging out from feide:" + error.Error() + ". HTTP status code: " + resp.Status)
logging.Logerror(error, "Error logging out of feide Auth.go:")
return false
}
......
......@@ -19,11 +19,11 @@ function logoutRequest(){
}).then((response) => response.json())
.then((json) => {
console.log(json, json.hash)
window.location.href= "/logout"
window.location.href= "https://auth.dataporten.no/openid/endsession"
})
.catch(function(error){
console.log(error)
window.location.href= "/logout"
window.location.href= "https://auth.dataporten.no/openid/endsession"
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment