Skip to content
Snippets Groups Projects
Commit a76be276 authored by Kristiane Skogvang Kolshus's avatar Kristiane Skogvang Kolshus
Browse files

Merge branch 'frontend-api-req' into 'main'

complete api requests for testing

See merge request !17
parents fd2edc47 d7d0233e
No related branches found
No related tags found
1 merge request!17complete api requests for testing
Pipeline #267990 passed
import axios from 'axios'; import axios from 'axios';
export const apiClient = axios.create({ export const apiClient = axios.create({
baseURL: '/api', baseURL: 'http://localhost:5173/api',
//TODO: set api URL //TODO: set api URL
}); });
\ No newline at end of file
...@@ -8,6 +8,7 @@ export default { ...@@ -8,6 +8,7 @@ export default {
//components: {Svg}, //components: {Svg},
data() { data() {
return { return {
username: '',
email: '', email: '',
password: '', password: '',
showPassword: false, // Add showPassword property showPassword: false, // Add showPassword property
...@@ -17,8 +18,8 @@ export default { ...@@ -17,8 +18,8 @@ export default {
methods: { methods: {
async handleSubmit() { async handleSubmit() {
try { try {
await apiClient.post('/login', { await apiClient.post('/auth/login', {
email: this.email, username: this.username,
password: this.password password: this.password
}).then(response => { }).then(response => {
setToken(response.data.token); //TODO: check token name setToken(response.data.token); //TODO: check token name
...@@ -43,14 +44,19 @@ export default { ...@@ -43,14 +44,19 @@ export default {
<h1 id="login">Login</h1> <h1 id="login">Login</h1>
<p> Sign in to your already existing account</p> <p> Sign in to your already existing account</p>
<div class="loginBox"> <div class="loginBox">
<label>Username</label> <br>
<input type="text" required v-model="username" placeholder="username"/> <br>
<!--
<label>Email</label> <br> <label>Email</label> <br>
<input type="email" placeholder="JohnDoe@email.com" required v-model="email"/> <br> <input type="email" placeholder="JohnDoe@email.com" required v-model="email"/> <br>
-->
<label>Password</label> <br> <label>Password</label> <br>
<input :type="showPassword ? 'text' : 'password'" required v-model="password"/> <input :type="showPassword ? 'text' : 'password'" required v-model="password"/>
<button type="button" class="showPasswordIcon" @click="togglePasswordVisibility"> <button type="button" class="showPasswordIcon" @click="togglePasswordVisibility">
<Svg v-if="showPassword" :name="'hide-password-icon'" /> <Svg v-if="showPassword" :name="'hide-password-icon'" />
<Svg v-else :name="'show-password-icon'" /> <Svg v-else :name="'show-password-icon'" />
</button><br> </button><br>
<label></label>{{errorMsg}}<br>
<router-link to="/signup" id="signUpLink">SIGNUP</router-link> <router-link to="/signup" id="signUpLink">SIGNUP</router-link>
</div> </div>
</div> </div>
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
name: 'Register', name: 'Register',
data(){ data(){
return{ return{
first_name:'', username: '',
last_name:'', //first_name:'',
email:'', //last_name:'',
//email:'',
password:'', password:'',
password_confirm:'', password_confirm:'',
errorMsg: '', //TODO: display error to user errorMsg: '', //TODO: display error to user
...@@ -18,10 +19,11 @@ ...@@ -18,10 +19,11 @@
async handleSubmit() { async handleSubmit() {
//TODO: use interceptor to check matching password, send one password //TODO: use interceptor to check matching password, send one password
try { try {
await apiClient.post('/api/auth/register', { await apiClient.post('/auth/register', {
first_name: this.first_name, //first_name: this.first_name,
last_name: this.last_name, //last_name: this.last_name,
email: this.email, //email: this.email,
username: this.username,
password: this.password password: this.password
//password_confirm: this.password_confirm //password_confirm: this.password_confirm
}).then(response => { }).then(response => {
...@@ -47,12 +49,17 @@ ...@@ -47,12 +49,17 @@
<h1 id="signup">Signup</h1> <h1 id="signup">Signup</h1>
<p> Create an account to get started!</p> <p> Create an account to get started!</p>
<div class="signupBox"> <div class="signupBox">
<label>First Name</label> <br>
<input type="text" required v-model="username" placeholder="username"/> <br>
<!--
<label>First Name</label> <br> <label>First Name</label> <br>
<input type="text" required v-model="first_name" placeholder="John"/> <br> <input type="text" required v-model="first_name" placeholder="John"/> <br>
<label>Last Name</label> <br> <label>Last Name</label> <br>
<input type="text" required v-model="last_name" placeholder="Doe"/> <br> <input type="text" required v-model="last_name" placeholder="Doe"/> <br>
<label>Email</label> <br> <label>Email</label> <br>
<input type="email" required v-model="email" placeholder="JohnDoe@email.com"/> <br> <input type="email" required v-model="email" placeholder="JohnDoe@email.com"/> <br>
-->
<label>Password</label> <br> <label>Password</label> <br>
<input type="text" required v-model="password" /> <br> <input type="text" required v-model="password" /> <br>
<label>Confirm Password</label> <br> <label>Confirm Password</label> <br>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment