refactor: manually renamed password fields
This commit is contained in:
@@ -78,17 +78,17 @@ func (q *Queries) CreateConfirmationCode(ctx context.Context, arg CreateConfirma
|
|||||||
|
|
||||||
const createLoginInformation = `-- name: CreateLoginInformation :one
|
const createLoginInformation = `-- name: CreateLoginInformation :one
|
||||||
INSERT INTO login_informations(user_id, email, password_hash)
|
INSERT INTO login_informations(user_id, email, password_hash)
|
||||||
VALUES ( $1, $2, crypt($3, gen_salt('bf')) ) RETURNING id, user_id, email, password_hash, totp_encrypted, email_2fa_enabled, password_change_date
|
VALUES ( $1, $2, crypt($3::text, gen_salt('bf')) ) RETURNING id, user_id, email, password_hash, totp_encrypted, email_2fa_enabled, password_change_date
|
||||||
`
|
`
|
||||||
|
|
||||||
type CreateLoginInformationParams struct {
|
type CreateLoginInformationParams struct {
|
||||||
UserID int64
|
UserID int64
|
||||||
Email pgtype.Text
|
Email pgtype.Text
|
||||||
Crypt string
|
Password string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) CreateLoginInformation(ctx context.Context, arg CreateLoginInformationParams) (LoginInformation, error) {
|
func (q *Queries) CreateLoginInformation(ctx context.Context, arg CreateLoginInformationParams) (LoginInformation, error) {
|
||||||
row := q.db.QueryRow(ctx, createLoginInformation, arg.UserID, arg.Email, arg.Crypt)
|
row := q.db.QueryRow(ctx, createLoginInformation, arg.UserID, arg.Email, arg.Password)
|
||||||
var i LoginInformation
|
var i LoginInformation
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
@@ -692,7 +692,7 @@ func (q *Queries) UpdateConfirmationCode(ctx context.Context, arg UpdateConfirma
|
|||||||
|
|
||||||
const updateLoginInformationByUsername = `-- name: UpdateLoginInformationByUsername :exec
|
const updateLoginInformationByUsername = `-- name: UpdateLoginInformationByUsername :exec
|
||||||
UPDATE login_informations
|
UPDATE login_informations
|
||||||
SET email = $2, password_hash = crypt($3, gen_salt('bf')), totp_encrypted = $4, email_2fa_enabled = $5, password_change_date = $6
|
SET email = $2, password_hash = crypt($3::text, gen_salt('bf')), totp_encrypted = $4, email_2fa_enabled = $5, password_change_date = $6
|
||||||
FROM users
|
FROM users
|
||||||
WHERE users.username = $1 AND login_informations.user_id = users.id
|
WHERE users.username = $1 AND login_informations.user_id = users.id
|
||||||
`
|
`
|
||||||
@@ -700,7 +700,7 @@ WHERE users.username = $1 AND login_informations.user_id = users.id
|
|||||||
type UpdateLoginInformationByUsernameParams struct {
|
type UpdateLoginInformationByUsernameParams struct {
|
||||||
Username string
|
Username string
|
||||||
Email pgtype.Text
|
Email pgtype.Text
|
||||||
Crypt string
|
Password string
|
||||||
TotpEncrypted pgtype.Text
|
TotpEncrypted pgtype.Text
|
||||||
Email2faEnabled pgtype.Bool
|
Email2faEnabled pgtype.Bool
|
||||||
PasswordChangeDate pgtype.Timestamp
|
PasswordChangeDate pgtype.Timestamp
|
||||||
@@ -710,7 +710,7 @@ func (q *Queries) UpdateLoginInformationByUsername(ctx context.Context, arg Upda
|
|||||||
_, err := q.db.Exec(ctx, updateLoginInformationByUsername,
|
_, err := q.db.Exec(ctx, updateLoginInformationByUsername,
|
||||||
arg.Username,
|
arg.Username,
|
||||||
arg.Email,
|
arg.Email,
|
||||||
arg.Crypt,
|
arg.Password,
|
||||||
arg.TotpEncrypted,
|
arg.TotpEncrypted,
|
||||||
arg.Email2faEnabled,
|
arg.Email2faEnabled,
|
||||||
arg.PasswordChangeDate,
|
arg.PasswordChangeDate,
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ WHERE users.username = $1;
|
|||||||
|
|
||||||
;-- name: CreateLoginInformation :one
|
;-- name: CreateLoginInformation :one
|
||||||
INSERT INTO login_informations(user_id, email, password_hash)
|
INSERT INTO login_informations(user_id, email, password_hash)
|
||||||
VALUES ( $1, $2, crypt($3, gen_salt('bf')) ) RETURNING *;
|
VALUES ( $1, $2, crypt(@password::text, gen_salt('bf')) ) RETURNING *;
|
||||||
|
|
||||||
;-- name: UpdateLoginInformationByUsername :exec
|
;-- name: UpdateLoginInformationByUsername :exec
|
||||||
UPDATE login_informations
|
UPDATE login_informations
|
||||||
SET email = $2, password_hash = crypt($3, gen_salt('bf')), totp_encrypted = $4, email_2fa_enabled = $5, password_change_date = $6
|
SET email = $2, password_hash = crypt(@password::text, gen_salt('bf')), totp_encrypted = $4, email_2fa_enabled = $5, password_change_date = $6
|
||||||
FROM users
|
FROM users
|
||||||
WHERE users.username = $1 AND login_informations.user_id = users.id;
|
WHERE users.username = $1 AND login_informations.user_id = users.id;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user