Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.

Commit 401b1c5

Browse files
fix(signup): better error handling + version bump
1 parent fddc9da commit 401b1c5

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="com.mobisys.android.ibp" version="3.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget id="com.mobisys.android.ibp" version="3.0.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
33
<name>IBP</name>
44
<description>Biodiversity India</description>
55
<author email="[email protected]" href="https://indiabiodiversity.org/">Strand Life Sciences</author>
@@ -112,6 +112,6 @@
112112
<variable name="PLAY_SERVICES_VERSION" value="11.8.0" />
113113
</plugin>
114114
<plugin name="com-sarriaroman-photoviewer" spec="1.2.1" />
115-
<engine name="android" spec="7.1.4" />
116115
<engine name="browser" spec="5.0.4" />
116+
<engine name="android" spec="7.1.4" />
117117
</widget>

src/app/pages/auth/signup/signup.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class SignupPage implements OnInit {
120120
this.redirectToLogin();
121121
} else {
122122
console.error(sResponse);
123-
this.basicUtilsService.showToast(sResponse.error.message);
123+
this.basicUtilsService.showToast(sResponse.errorText);
124124
}
125125
}
126126

src/app/services/authentication/authentication.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ export class AuthenticationService {
7272
* Sends signup request to servers
7373
* @param formData
7474
* @returns Can be access token or user details if user is not registered to portal
75+
* @info If it's 200 that means registration is done successfully
7576
*/
7677
async signup(f): Promise<any> {
78+
let errorText = `Error`;
7779
const signupForm = {
7880
email: f.email,
7981
"g-recaptcha-response": f.captcha,
@@ -90,11 +92,17 @@ export class AuthenticationService {
9092
webaddress: ""
9193
};
9294
try {
93-
return await this.http.post("register", signupForm).toPromise();
95+
await this.http.post("register", signupForm).toPromise();
96+
return { success: true };
9497
} catch (e) {
9598
console.error(e);
99+
if (Array.isArray(e.error)) {
100+
e.error.forEach(({ message, path }) => {
101+
errorText += `\n${path}: ${message}`;
102+
});
103+
}
96104
}
97-
return false;
105+
return { success: false, errorText };
98106
}
99107

100108
/**

0 commit comments

Comments
 (0)