-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(email): create and send verify email
- Loading branch information
Showing
15 changed files
with
236 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ REFRESH_TOKEN_DURATION=24h | |
REDIS_ADDRESS=0.0.0.0:6379 | ||
EMAIL_SENDER_NAME=Simple Bank | ||
EMAIL_SENDER_ADDRESS=[email protected] | ||
EMAIL_SENDER_PASSWORD=prgctnuzmwqlkcrn | ||
EMAIL_SENDER_PASSWORD=prgctnuzmwqlkcrn | ||
EMAIL_VERIFY_ADDRESS=https://localhost:8080/v1/verify_email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP TABLE IF EXISTS "verify_emails" CASCADE; | ||
|
||
ALTER TABLE "users" DROP COLUMN "is_email_verified"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE TABLE "verify_emails" ( | ||
"id" bigserial PRIMARY KEY, | ||
"username" varchar NOT NULL, | ||
"email" varchar NOT NULL, | ||
"secret_code" varchar NOT NULL, | ||
"is_used" bool NOT NULL DEFAULT false, | ||
"created_at" timestamptz NOT NULL DEFAULT (now()), | ||
"expired_at" timestamptz NOT NULL DEFAULT (now() + interval '15 minutes') | ||
); | ||
|
||
ALTER TABLE "verify_emails" ADD FOREIGN KEY ("username") REFERENCES "users" ("username"); | ||
|
||
ALTER TABLE "users" ADD COLUMN "is_email_verified" bool NOT NULL DEFAULT false; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- name: CreateVerifyEmail :one | ||
INSERT INTO verify_emails ( | ||
username, | ||
email, | ||
secret_code | ||
) VALUES ( | ||
$1, $2, $3 | ||
) RETURNING *; | ||
|
||
-- name: UpdateVerifyEmail :one | ||
UPDATE verify_emails | ||
SET | ||
is_used = TRUE | ||
WHERE | ||
id = @id | ||
AND secret_code = @secret_code | ||
AND is_used = FALSE | ||
AND expired_at > now() | ||
RETURNING *; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.