Skip to content

Commit

Permalink
#35 add key auth
Browse files Browse the repository at this point in the history
  • Loading branch information
kynmh69 committed Oct 13, 2024
1 parent 4144874 commit 7e2e94e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/api/.air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ tmp_dir = "tmp"

[log]
main_only = false
silent = false
time = false

[misc]
clean_on_exit = false

[proxy]
app_port = 0
enabled = false
proxy_port = 0

[screen]
clear_on_rebuild = false
keep_scroll = true
6 changes: 5 additions & 1 deletion src/model/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ func GetApiKeys() ([]ApiKey, error) {
}

func GetApiKey(apiKeyStr string) (ApiKey, error) {
logger := logging.GetLogger()
var apiKey ApiKey
db := database.GetDbConnection()
err := db.First(&apiKey).Where("key = ?", apiKeyStr).Error
err := db.Where("key = ?", apiKeyStr).First(&apiKey).Error
if err != nil {
logger.Debug("API key is invalid. ", apiKeyStr)
}
return apiKey, err
}

Expand Down

0 comments on commit 7e2e94e

Please sign in to comment.