Skip to content

Commit

Permalink
INTG-3224 fix api key validation (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
MickStanciu authored Feb 4, 2024
1 parent 1773490 commit 4c2c5f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ func (a *App) ValidateApiKey(apiKey string) string {

if err != nil {
runtime.LogErrorf(a.ctx, "cannot check WhoAmI: %s", err.Error())
return err.Error()
return "cannot validate the credentials for the given ApiKey"
}

if res != nil && (res.UserID == "" || res.OrganisationID == "") {
runtime.LogErrorf(a.ctx, "cannot validate the credentials for the given ApiKey: %s", err.Error())
return err.Error()
if res == nil || (res != nil && res.UserID == "" || res.OrganisationID == "") {
runtime.LogErrorf(a.ctx, "cannot validate the credentials for the given ApiKey: %s", apiKey)
return "cannot validate the credentials for the given ApiKey"
}

runtime.LogInfo(a.ctx, "saving the key")
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/Init.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
} else {
// check if it can auth
return ValidateApiKey(token).then(res => {
if (res === false) {
if (res !== "") {
return '/welcome'
} else {
return '/config'
Expand Down

0 comments on commit 4c2c5f8

Please sign in to comment.