Skip to content

Commit

Permalink
Merge pull request #13 from zjf19002/nic21003_experimental
Browse files Browse the repository at this point in the history
login routing change
  • Loading branch information
tjb20007 authored Nov 6, 2023
2 parents ea0f998 + fa47b59 commit ce91b9f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions class_registration_app/src/components/LoginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<form class="loginbox" autocomplete="off">
<input placeholder="Username" type="text" id="username" v-model="data.username" />
<input placeholder="Password" type="password" id="password" v-model="data.password"/>
<RouterLink v-if="!authenticationFailed" to="./dashboard" @click.prevent="tryLogin"> <!--use v-if here-->
<button id="submit">Login</button>
</RouterLink>
<!--<RouterLink to="./dashboard" @click.prevent="tryLogin"> use v-if here @click.prevent="tryLogin" -->
<button @click.prevent="tryLogin" id="submit">Login</button>
</form>
<RouterLink to="/">Back</RouterLink>
</section>
Expand All @@ -34,24 +33,19 @@ const tryLogin = async () => {
// Enter query parameters here
},
});
console.log(response.data);
const res = response.data;
const authenticationValid = (res.statusCode === 200);
if (authenticationSucceeds(res)) {
await router.push({path: '/dashboard'});
} else {
authenticationFailed = true;
if (authenticationValid === true) {
router.push({path: './dashboard'});
}
} catch (error) {
console.error(error);
authenticationFailed = true;
const authenticationValid = false;
}
};
const authenticationSucceeds = (response) => {
return response.data && response.data.statusCode === 200;
};
</script>

<style scoped>
Expand Down

0 comments on commit ce91b9f

Please sign in to comment.