feat: 0.0.1
This commit is contained in:
146 files changed
+10444
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type VerifyEmailTxParams struct {
|
||||
EmailID int64
|
||||
SecretCode string
|
||||
}
|
||||
|
||||
type VerifyEmailTxResult struct {
|
||||
User User
|
||||
VerifyEmail VerifyEmail
|
||||
}
|
||||
|
||||
func (store *PostgresStore) VerifyEmailTx(ctx context.Context, arg VerifyEmailTxParams) (VerifyEmailTxResult, error) {
|
||||
var result VerifyEmailTxResult
|
||||
|
||||
err := store.execTx(ctx, func(q *Queries) error {
|
||||
var err error
|
||||
|
||||
result.VerifyEmail, err = q.UpdateVerifyEmail(ctx, UpdateVerifyEmailParams{
|
||||
ID: arg.EmailID,
|
||||
SecretCode: arg.SecretCode,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result.User, err = q.UpdateUser(ctx, UpdateUserParams{
|
||||
Username: result.VerifyEmail.Username,
|
||||
IsEmailVerified: pgtype.Bool{
|
||||
Bool: true,
|
||||
Valid: true,
|
||||
},
|
||||
})
|
||||
|
||||
return err
|
||||
})
|
||||
return result, err
|
||||
}
|
||||
Reference in new issue
Block a user