fix up typos
This commit is contained in:
parent
a9278183e4
commit
6d49719f00
12
pastebin.go
12
pastebin.go
|
@ -993,25 +993,25 @@ func getUserKey(r *http.Request) string {
|
||||||
func generateKey() string {
|
func generateKey() string {
|
||||||
|
|
||||||
// Use uniuri to generate random string
|
// Use uniuri to generate random string
|
||||||
id := uniuri.NewLen(20)
|
key := uniuri.NewLen(20)
|
||||||
loggy(fmt.Sprintf("Generated id is '%s', checking if it's already taken in the database",
|
loggy(fmt.Sprintf("Generated id is '%s', checking if it's already taken in the database",
|
||||||
id))
|
key))
|
||||||
|
|
||||||
// Query database if id exists and if it does call generateName again
|
// Query database if id exists and if it does call generateName again
|
||||||
var key_taken string
|
var key_taken string
|
||||||
err := dbHandle.QueryRow("select key from "+configuration.DBAccountsTable+
|
err := dbHandle.QueryRow("select key from "+configuration.DBAccountsTable+
|
||||||
" where key="+configuration.DBPlaceHolder[0], id).
|
" where key="+configuration.DBPlaceHolder[0], key).
|
||||||
Scan(&key_taken)
|
Scan(&key_taken)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case err == sql.ErrNoRows:
|
case err == sql.ErrNoRows:
|
||||||
loggy(fmt.Sprintf("Key '%s' is not taken, will use it.", id))
|
loggy(fmt.Sprintf("Key '%s' is not taken, will use it.", key))
|
||||||
case err != nil:
|
case err != nil:
|
||||||
debugLogger.Println(" Database error : " + err.Error())
|
debugLogger.Println(" Database error : " + err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
default:
|
default:
|
||||||
loggy(fmt.Sprintf("Key '%s' is taken, generating new id.", id_taken))
|
loggy(fmt.Sprintf("Key '%s' is taken, generating new key.", key_taken))
|
||||||
generateName()
|
generateKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
return key
|
return key
|
||||||
|
|
Loading…
Reference in New Issue