Skip to content

Commit c94a1e4

Browse files
committed
beginnings of route to display success/error of user confirming email - added confirm route that submits PUT request to backend with error handling
1 parent 86d684b commit c94a1e4

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

app/router.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Router.map(function() {
4545
this.route('catchAll', { path: '*path' });
4646
this.route('team', { path: '/teams/:team_id' });
4747
this.route('policies');
48+
this.route('confirm', { path: '/confirm/:email_token' });
4849
});
4950

5051
export default Router;

app/routes/confirm.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Ember from 'ember';
2+
import { inject as service } from '@ember/service';
3+
4+
export default Ember.Route.extend({
5+
flashMessages: service(),
6+
ajax: service(),
7+
8+
model(params) {
9+
console.log(params);
10+
11+
return this.get('ajax').raw(`/api/v1/confirm/${params.email_token}`, { method: 'PUT', data: {}})
12+
.then(({response}) => {
13+
console.log("response: " + response)
14+
})
15+
.catch((error) => {
16+
console.log(error.payload);
17+
if (error.payload) {
18+
console.log("finding error in payload: " + error.payload.errors[0].detail);
19+
this.get('flashMessages').queue(`Error in email confirmation: ${error.payload.errors[0].detail}`);
20+
return;
21+
} else {
22+
this.get('flashMessages').queue(`Unknown error in email confirmation`);
23+
return;
24+
}
25+
});
26+
}
27+
});

app/templates/confirm/error.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Something went wrong in confirm</h1>

app/templates/confirm/index.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Thanks for confimring</h1>

0 commit comments

Comments
 (0)