Remove unnecessary var data in log messages. Closes #1640
This commit is contained in:
@@ -42,7 +42,7 @@ var validAccessTokenScopes = []string{
|
||||
|
||||
// InsertExternalAPIUser will add a new API user to the database.
|
||||
func InsertExternalAPIUser(token string, name string, color int, scopes []string) error {
|
||||
log.Traceln("Adding new API user:", name)
|
||||
log.Traceln("Adding new API user")
|
||||
|
||||
_datastore.DbLock.Lock()
|
||||
defer _datastore.DbLock.Unlock()
|
||||
@@ -55,7 +55,6 @@ func InsertExternalAPIUser(token string, name string, color int, scopes []string
|
||||
return err
|
||||
}
|
||||
stmt, err := tx.Prepare("INSERT INTO users(id, access_token, display_name, display_color, scopes, type, previous_names) values(?, ?, ?, ?, ?, ?, ?)")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,7 +73,7 @@ func InsertExternalAPIUser(token string, name string, color int, scopes []string
|
||||
|
||||
// DeleteExternalAPIUser will delete a token from the database.
|
||||
func DeleteExternalAPIUser(token string) error {
|
||||
log.Traceln("Deleting access token:", token)
|
||||
log.Traceln("Deleting access token")
|
||||
|
||||
_datastore.DbLock.Lock()
|
||||
defer _datastore.DbLock.Unlock()
|
||||
@@ -84,7 +83,6 @@ func DeleteExternalAPIUser(token string) error {
|
||||
return err
|
||||
}
|
||||
stmt, err := tx.Prepare("UPDATE users SET disabled_at = ? WHERE access_token = ?")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -113,7 +111,7 @@ func GetExternalAPIUserForAccessTokenAndScope(token string, scope string) (*Exte
|
||||
// so we can efficiently find if a token supports a single scope.
|
||||
// This is SQLite specific, so if we ever support other database
|
||||
// backends we need to support other methods.
|
||||
var query = `SELECT id, access_token, scopes, display_name, display_color, created_at, last_used FROM (
|
||||
query := `SELECT id, access_token, scopes, display_name, display_color, created_at, last_used FROM (
|
||||
WITH RECURSIVE split(id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, scope, rest) AS (
|
||||
SELECT id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, '', scopes || ',' FROM users
|
||||
UNION ALL
|
||||
@@ -122,8 +120,8 @@ func GetExternalAPIUserForAccessTokenAndScope(token string, scope string) (*Exte
|
||||
substr(rest, instr(rest, ',')+1)
|
||||
FROM split
|
||||
WHERE rest <> '')
|
||||
SELECT id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, scope
|
||||
FROM split
|
||||
SELECT id, access_token, scopes, display_name, display_color, created_at, last_used, disabled_at, scope
|
||||
FROM split
|
||||
WHERE scope <> ''
|
||||
ORDER BY access_token, scope
|
||||
) AS token WHERE token.access_token = ? AND token.scope = ?`
|
||||
@@ -141,7 +139,6 @@ func GetIntegrationNameForAccessToken(token string) *string {
|
||||
|
||||
var name string
|
||||
err := row.Scan(&name)
|
||||
|
||||
if err != nil {
|
||||
log.Warnln(err)
|
||||
return nil
|
||||
@@ -153,7 +150,7 @@ func GetIntegrationNameForAccessToken(token string) *string {
|
||||
// GetExternalAPIUser will return all access tokens.
|
||||
func GetExternalAPIUser() ([]ExternalAPIUser, error) { //nolint
|
||||
// Get all messages sent within the past day
|
||||
var query = "SELECT id, access_token, display_name, display_color, scopes, created_at, last_used FROM users WHERE type IS 'API' AND disabled_at IS NULL"
|
||||
query := "SELECT id, access_token, display_name, display_color, scopes, created_at, last_used FROM users WHERE type IS 'API' AND disabled_at IS NULL"
|
||||
|
||||
rows, err := _datastore.DB.Query(query)
|
||||
if err != nil {
|
||||
@@ -173,7 +170,6 @@ func SetExternalAPIUserAccessTokenAsUsed(token string) error {
|
||||
return err
|
||||
}
|
||||
stmt, err := tx.Prepare("UPDATE users SET last_used = CURRENT_TIMESTAMP WHERE access_token = ?")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -256,7 +252,6 @@ func HasValidScopes(scopes []string) bool {
|
||||
for _, scope := range scopes {
|
||||
_, foundInSlice := utils.FindInSlice(validAccessTokenScopes, scope)
|
||||
if !foundInSlice {
|
||||
log.Errorln("Invalid scope", scope)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user