summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar André Oliveira <oliveira.andrerodrigues95@gmail.com>2023-09-28 16:11:37 +0100
committerLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2023-09-30 10:13:48 +0100
commitec0914ae254af409da1f0b775460d5234b6484b7 (patch)
treea72acbd7cea38b0e68a31b311de6da1c9fed244e /src
parent6.5.0-nightly.19 [skip ci] (diff)
downloadferdium-app-ec0914ae254af409da1f0b775460d5234b6484b7.tar.gz
ferdium-app-ec0914ae254af409da1f0b775460d5234b6484b7.tar.zst
ferdium-app-ec0914ae254af409da1f0b775460d5234b6484b7.zip
fix: login and signup error messages
Diffstat (limited to 'src')
-rw-r--r--src/api/server/ServerApi.ts36
-rw-r--r--src/components/auth/Login.tsx38
-rw-r--r--src/components/auth/Signup.tsx6
3 files changed, 48 insertions, 32 deletions
diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts
index 7b17fcdcd..8e1d45588 100644
--- a/src/api/server/ServerApi.ts
+++ b/src/api/server/ServerApi.ts
@@ -62,13 +62,19 @@ export default class ServerApi {
62 }, 62 },
63 false, 63 false,
64 ); 64 );
65 if (!request.ok) { 65 try {
66 throw new Error(request.statusText); 66 const responseJson = await request.json();
67 }
68 const u = await request.json();
69 67
70 debug('ServerApi::login resolves', u); 68 if (!request.ok) {
71 return u.token; 69 throw responseJson;
70 }
71
72 debug('ServerApi::login resolves', responseJson);
73 return responseJson.token;
74 } catch (error) {
75 debug('ServerApi::login ERROR:', error);
76 throw error;
77 }
72 } 78 }
73 79
74 async signup(data: any) { 80 async signup(data: any) {
@@ -80,13 +86,19 @@ export default class ServerApi {
80 }, 86 },
81 false, 87 false,
82 ); 88 );
83 if (!request.ok) { 89 try {
84 throw new Error(request.statusText); 90 const responseJson = await request.json();
85 }
86 const u = await request.json();
87 91
88 debug('ServerApi::signup resolves', u); 92 if (!request.ok) {
89 return u.token; 93 throw responseJson;
94 }
95
96 debug('ServerApi::signup resolves', responseJson);
97 return responseJson.token;
98 } catch (error) {
99 debug('ServerApi::signup ERROR:', error);
100 throw error;
101 }
90 } 102 }
91 103
92 async inviteUser(data: any) { 104 async inviteUser(data: any) {
diff --git a/src/components/auth/Login.tsx b/src/components/auth/Login.tsx
index cf7abe654..9bad731c8 100644
--- a/src/components/auth/Login.tsx
+++ b/src/components/auth/Login.tsx
@@ -139,26 +139,30 @@ class Login extends Component<IProps> {
139 <Input {...form.$('password').bind()} showPasswordToggle /> 139 <Input {...form.$('password').bind()} showPasswordToggle />
140 {error.code === 'invalid-credentials' && ( 140 {error.code === 'invalid-credentials' && (
141 <> 141 <>
142 <p className="error-message center"> 142 <h2 className="error-message center">
143 {intl.formatMessage(messages.invalidCredentials)} 143 {intl.formatMessage(messages.invalidCredentials)}
144 </p> 144 </h2>
145 {window['ferdium'].stores.settings.all.app.server !== 145 {window['ferdium'].stores.settings.all.app.server !==
146 LIVE_FRANZ_API && ( 146 LIVE_FRANZ_API && (
147 <p className="error-message center"> 147 <>
148 {intl.formatMessage(messages.customServerQuestion)}{' '} 148 <p className="error-message center">
149 <Link 149 {intl.formatMessage(messages.customServerQuestion)}{' '}
150 to={`${window[ 150 </p>
151 'ferdium' 151 <p className="error-message center">
152 ].stores.settings.all.app.server.replace( 152 <Link
153 API_VERSION, 153 to={`${window[
154 '', 154 'ferdium'
155 )}/import`} 155 ].stores.settings.all.app.server.replace(
156 target="_blank" 156 API_VERSION,
157 style={{ cursor: 'pointer', textDecoration: 'underline' }} 157 '',
158 > 158 )}/import`}
159 {intl.formatMessage(messages.customServerSuggestion)} 159 target="_blank"
160 </Link> 160 style={{ cursor: 'pointer', textDecoration: 'underline' }}
161 </p> 161 >
162 {intl.formatMessage(messages.customServerSuggestion)}
163 </Link>
164 </p>
165 </>
162 )} 166 )}
163 </> 167 </>
164 )} 168 )}
diff --git a/src/components/auth/Signup.tsx b/src/components/auth/Signup.tsx
index fb2a2360e..06a9774aa 100644
--- a/src/components/auth/Signup.tsx
+++ b/src/components/auth/Signup.tsx
@@ -148,10 +148,10 @@ class Signup extends Component<IProps> {
148 showPasswordToggle 148 showPasswordToggle
149 scorePassword 149 scorePassword
150 /> 150 />
151 {error.code === 'email-duplicate' && ( 151 {error.status === 401 && (
152 <p className="error-message center"> 152 <h2 className="error-message center">
153 {intl.formatMessage(messages.emailDuplicate)} 153 {intl.formatMessage(messages.emailDuplicate)}
154 </p> 154 </h2>
155 )} 155 )}
156 {isSubmitting ? ( 156 {isSubmitting ? (
157 <Button 157 <Button