2023-10-15 17:32:11 +02:00
|
|
|
import Route from '@ember/routing/route';
|
2020-01-18 10:13:50 +01:00
|
|
|
import { action } from '@ember/object';
|
2018-12-29 01:27:37 +01:00
|
|
|
import { inject as service } from '@ember/service';
|
2014-10-30 21:44:22 +01:00
|
|
|
|
2020-01-18 10:13:50 +01:00
|
|
|
export default class PollRoute extends Route {
|
2023-10-15 17:32:11 +02:00
|
|
|
@service encryption;
|
|
|
|
@service router;
|
2023-10-15 21:50:28 +02:00
|
|
|
@service store;
|
2023-10-15 17:32:11 +02:00
|
|
|
|
2020-01-18 10:13:50 +01:00
|
|
|
@action
|
|
|
|
error(error) {
|
|
|
|
if (error && error.status === 404) {
|
2023-10-15 17:32:11 +02:00
|
|
|
return this.router.transitionTo('404');
|
2014-10-28 06:00:37 +01:00
|
|
|
}
|
2015-08-19 22:00:01 +02:00
|
|
|
|
2020-01-18 10:13:50 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-28 23:48:14 +01:00
|
|
|
model(params) {
|
2015-08-19 22:00:01 +02:00
|
|
|
// get encryption key from query parameter in singleton
|
|
|
|
// before it's used by serializer to decrypt payload
|
|
|
|
this.set('encryption.key', params.encryptionKey);
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-01-31 15:30:31 +01:00
|
|
|
return this.store.find('poll', params.poll_id);
|
2020-01-18 10:13:50 +01:00
|
|
|
}
|
2015-11-04 12:09:42 +01:00
|
|
|
|
2016-03-18 20:26:41 +01:00
|
|
|
redirect(poll, transition) {
|
|
|
|
if (transition.targetName === 'poll.index') {
|
2023-10-15 21:50:28 +02:00
|
|
|
this.router.transitionTo('poll.participation', poll, {
|
2016-03-18 20:26:41 +01:00
|
|
|
queryParams: {
|
2023-10-15 20:37:03 +02:00
|
|
|
encryptionKey: this.encryption.key,
|
|
|
|
},
|
2016-03-18 20:26:41 +01:00
|
|
|
});
|
|
|
|
}
|
2014-10-28 06:00:37 +01:00
|
|
|
}
|
2020-01-18 10:13:50 +01:00
|
|
|
}
|