Skip to content

Commit

Permalink
feat(ember): add support page
Browse files Browse the repository at this point in the history
redirect to support page when receiving specific identity error
  • Loading branch information
Yelinz committed Jan 23, 2025
1 parent a7b862d commit 58ecaca
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions ember/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const resetNamespace = true;
//eslint-disable-next-line array-callback-return
Router.map(function () {
this.route("login");
this.route("support");
this.route("notfound", { path: "/*path" });

this.route("protected", { path: "/" }, function () {
Expand Down
42 changes: 28 additions & 14 deletions ember/app/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ENV from "mysagw/config/environment";

export default class CustomSession extends Session {
@service store;
@service router;

currentIdentity = trackedTask(this, this.fetchCurrentIdentity, () => [
this.isAuthenticated,
Expand All @@ -18,21 +19,34 @@ export default class CustomSession extends Session {

if (!this.isAuthenticated) return null;

const data = yield Promise.all([
this.store.query(
"membership",
{
include: "organisation",
},
{ adapterOptions: { customEndpoint: "my-memberships" } },
),
this.store.queryRecord("identity", {}),
]);
try {
const data = yield Promise.all([
this.store.query(
"membership",
{
include: "organisation",
},
{ adapterOptions: { customEndpoint: "my-memberships" } },
),
this.store.queryRecord("identity", {}),
]);

return {
memberships: data[0],
identity: data[1],
};
} catch (error) {
this.invalidate();

if (
error.errors[0].detail ===
"Can't create Identity, because there is already an organisation with this email address."
) {
return this.router.transitionTo("support");
}

return {
memberships: data[0],
identity: data[1],
};
return this.router.transitionTo("login");
}
}

get identity() {
Expand Down
3 changes: 3 additions & 0 deletions ember/app/ui/support/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from "@ember/routing/route";

export default class SupportRoute extends Route { }

Check failure on line 3 in ember/app/ui/support/route.js

View workflow job for this annotation

GitHub Actions / ember-test

Delete `·`
6 changes: 6 additions & 0 deletions ember/app/ui/support/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="uk-text-center">
<h1>{{t "support.title"}}</h1>
<h3>{{t "support.subtitle"}}
<a href="mailto:[email protected]" target="_blank" rel="noreferrer">[email protected]</a>
</h3>
</div>
3 changes: 3 additions & 0 deletions ember/translations/support/de.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
support:
title: "Es besteht ein Fehler mit ihrem Benutzerkonto."
subtitle: "Bitte kontaktieren Sie den Support unter"
3 changes: 3 additions & 0 deletions ember/translations/support/en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
support:
title: "There is an error with your user account."
subtitle: "Please contact support at"
3 changes: 3 additions & 0 deletions ember/translations/support/fr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
support:
title: "Il y a une erreur avec votre compte d'utilisateur."
subtitle: "Veuillez contacter le support à"

0 comments on commit 58ecaca

Please sign in to comment.