Connect wallet and fill in address during signup

In case there's a wallet available, ask the user to connect it and fill
in their account address in the form field.

Also, check the status code when submitting it to the back-end and show
an error message instead of the success/completion page in case the
contributor could not be created.
This commit is contained in:
Râu Cao
2023-01-21 12:39:14 +08:00
parent 1e7d8491f9
commit 0bdb4d2021
2 changed files with 55 additions and 45 deletions
+12 -6
View File
@@ -2,16 +2,22 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { isEmpty } from '@ember/utils';
export default Route.extend({
export default class SignupAccountRoute extends Route {
@service kredits;
kredits: service(),
async setupController (controller) {
if (!window.ethereum) return;
if (this.kredits.hasAccounts) {
controller.accountAddress = this.kredits.currentUserAccounts.firstObject;
} else {
return this.kredits.connectWallet();
}
}
redirect () {
this._super(...arguments);
if (isEmpty(this.kredits.githubAccessToken)) {
this.transitionTo('signup.index');
}
}
});
}