Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 8a51e16

Browse files
committed
handle raspberry-linked login response message
1 parent eae0b95 commit 8a51e16

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

json-server/server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ server.post('/api/2.0/users/login', (req, res) => {
160160
res.send();
161161
} else if (req.body.email === '[email protected]') {
162162
res.send({ ok: false, why: 'invalid-password' });
163+
} else if (req.body.email === '[email protected]') {
164+
res.send({ ok: false, why: 'raspberry-linked' });
163165
} else {
164166
res.send({ ok: false, why: 'user-not-found' });
165167
}

src/users/cd-login.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<p class="cd-login__password-req-err text-danger" v-show="errors.has('password:required')">{{ $t('Password is required') }}</p>
2727
<input class="cd-login__button btn btn-primary" type="submit" value="Login" />
2828
</form>
29-
<p v-show="errors.has('loginFailed')" class="cd-login__login-failed text-danger">{{ $t('There was a problem logging in: {msg}', {msg: $t('Invalid email or password') }) }}</p>
29+
<p v-show="errors.has('invalid-password')" class="cd-login__login-failed text-danger">{{ $t('There was a problem logging in: {msg}', {msg: $t('Invalid email or password') }) }}</p>
30+
<p v-show="errors.has('raspberry-linked')" class="cd-login__login-failed text-danger">{{ $t('There was a problem logging in: {msg}', {msg: $t('Account linked to a My Raspberry Pi account.') }) }}<a href='/rpi/login'>{{$t('Click here to login through My Raspberry Pi')}}</a>{{$t('Remember to use the same email address!')}}</p>
3031
<p class="cd-login__forgot-password"><a href="/reset">{{ $t('Forgot password?') }}</a></p>
3132
<p class="cd-login__register">{{ $t("Don't have an account?") }} <a :href="registerUrl">{{ $t('Register here') }}</a></p>
3233
</div>
@@ -81,9 +82,7 @@
8182
if (valid) {
8283
const response = await UserService.login(this.email, this.password);
8384
if (response.body.ok === false) {
84-
this.errors.add({
85-
field: 'loginFailed',
86-
msg: response.body.why });
85+
this.errors.add({ field: response.body.why });
8786
} else {
8887
const forumUrl = `^${Vue.config.forumsUrlBase}/auth/CoderDojo$`;
8988
if (this.redirectUrl.match(forumUrl)) {

0 commit comments

Comments
 (0)