-
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(auth): add update of email/password
- Loading branch information
Showing
19 changed files
with
612 additions
and
65 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,15 @@ export class UserSeeder extends BaseSeeder { | |
name: 'Admin', | ||
email: '[email protected]', | ||
password: await bcrypt.hash('12345', 10), | ||
emailToken: Uuid.generate(), | ||
token: Uuid.generate(), | ||
emailVerifiedAt: new Date() | ||
}) | ||
|
||
const userCustomer = await User.create({ | ||
name: 'Customer', | ||
email: '[email protected]', | ||
password: await bcrypt.hash('12345', 10), | ||
emailToken: Uuid.generate(), | ||
token: Uuid.generate(), | ||
emailVerifiedAt: new Date() | ||
}) | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,20 +7,50 @@ export default class QueueWorkerProvider extends ServiceProvider { | |
public intervals = [] | ||
|
||
public async boot() { | ||
this.processByQueue('user:register', async user => { | ||
this.processByQueue('user:confirm', async user => { | ||
return Mail.from('[email protected]') | ||
.to(user.email) | ||
.subject('Athenna Account Activation') | ||
.view('mail/register', { user }) | ||
.subject('Athenna Account Confirmation') | ||
.view('mail/confirm', { user }) | ||
.send() | ||
}) | ||
|
||
this.processByQueue('user:email', async ({ user, token, email }) => { | ||
return Mail.from('[email protected]') | ||
.to(user.email) | ||
.subject('Athenna Email Change') | ||
.view('mail/change-email', { user, email, token }) | ||
.send() | ||
}) | ||
|
||
this.processByQueue('user:password', async ({ user, token, password }) => { | ||
return Mail.from('[email protected]') | ||
.to(user.email) | ||
.subject('Athenna Password Change') | ||
.view('mail/change-password', { user, password, token }) | ||
.send() | ||
}) | ||
|
||
this.processByQueue( | ||
'user:email:password', | ||
async ({ user, token, email, password }) => { | ||
return Mail.from('[email protected]') | ||
.to(user.email) | ||
.subject('Athenna Email & Password Change') | ||
.view('mail/change-email-password', { user, email, password, token }) | ||
.send() | ||
} | ||
) | ||
} | ||
|
||
public async shutdown() { | ||
this.intervals.forEach(interval => clearInterval(interval)) | ||
} | ||
|
||
public processByQueue(queueName: string, processor: any) { | ||
public processByQueue( | ||
queueName: string, | ||
processor: (data: any) => any | Promise<any> | ||
) { | ||
const interval = setInterval(async () => { | ||
const queue = await Queue.queue(queueName) | ||
|
||
|
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,84 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Change Email & Password</title> | ||
<style> | ||
body { | ||
font-family: '-apple-system', 'BlinkMacSystemFont', 'Helvetica', 'Arial', 'sans-serif', 'apple color emoji'; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #252529; | ||
color: #e3e3e3; | ||
text-align: center; | ||
} | ||
.header { | ||
background-color: #1d1e25; | ||
padding: 20px; | ||
} | ||
.header h1 { | ||
margin: 0; | ||
font-size: 30px; | ||
} | ||
.activation { | ||
padding: 10px 100px; | ||
} | ||
.activation p { | ||
margin: 0; | ||
font-size: 20px; | ||
margin-top: 10px; | ||
margin-bottom: 30px; | ||
} | ||
.help { | ||
padding: 10px 200px; | ||
} | ||
.help p { | ||
margin: 0; | ||
font-size: 16px; | ||
margin-top: 10px; | ||
margin-bottom: 30px; | ||
} | ||
a { | ||
color: #ffff92; | ||
} | ||
a.button { | ||
padding: 10px 24px; | ||
border: 1px; | ||
font-size: 20px; | ||
border-radius: 3px; | ||
color: #e3e3e3; | ||
font-weight: 500; | ||
background-color: #715bf6; | ||
text-decoration: none; | ||
} | ||
.minerva-img { | ||
max-width: 200px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="header"> | ||
<img src="https://athenna.io/img/logos/minerva.png" alt="Minerva Logo" class="minerva-img"> | ||
<h1>Hey there {{ user.name }}!</h1> | ||
</div> | ||
<div class="activation"> | ||
<p> | ||
We are sending you this email because you have requested to | ||
change your account email to <b>{{ email }}</b> and also to | ||
change your <b>password</b>. To confirm the update, click the link bellow: | ||
</p> | ||
<a class="button" href="{{ `${Config.get('http.url')}/api/v1/confirm/email/password?token=${token}&email=${email}&password=${password}` }}">CONFIRM EMAIL & PASSWORD CHANGE</a> | ||
</div> | ||
<div class="help"> | ||
<p> | ||
If this was not you or if you have any questions, please email us | ||
at <a href="mailto:[email protected]">[email protected]</a> or | ||
visit our FAQS, you can also chat with a real human during our | ||
operating hours. They can answer questions about your account. | ||
</p> | ||
</div> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.