Fix user alias availability check (#832)

Related to #831

Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
This commit is contained in:
Sergio C. Arteaga 2020-11-09 09:03:53 +01:00 committed by GitHub
parent 40ce3f423f
commit 98d2f75f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 13 deletions

View File

@ -18,7 +18,13 @@ import (
const ( const (
// Database queries // Database queries
checkUserAliasAvailDBQ = `select user_id from "user" where alias = $1` checkUserAliasAvailDBQ = `
select user_id
from "user" u
join email_verification_code c using (user_id)
where u.alias = $1
and current_timestamp - '1 day'::interval < c.created_at
`
checkUserCredsDBQ = `select user_id, password from "user" where email = $1 and password is not null and email_verified = true` checkUserCredsDBQ = `select user_id, password from "user" where email = $1 and password is not null and email_verified = true`
deleteSessionDBQ = `delete from session where session_id = $1` deleteSessionDBQ = `delete from session where session_id = $1`
getAPIKeyUserIDDBQ = `select user_id from api_key where key = $1` getAPIKeyUserIDDBQ = `select user_id from api_key where key = $1`