Skip to content

login routing change #13

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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