forked from kompetenzinventar/ki-frontend
This commit is contained in:
@ -43,10 +43,11 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import RequestMixin from "@/mixins/request.mixin"
|
||||
|
||||
export default {
|
||||
name: "Index",
|
||||
mixins: [RequestMixin],
|
||||
data() {
|
||||
return {
|
||||
showErrorMessage: false,
|
||||
@ -54,31 +55,5 @@ export default {
|
||||
password: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async submitLogin() {
|
||||
this.showErrorMessage = false;
|
||||
try {
|
||||
const loginResult = await axios.post(
|
||||
`${this.apiUrl}/users/login`,
|
||||
{
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
}
|
||||
);
|
||||
if (loginResult.status === 200) {
|
||||
this.showErrorMessage = false;
|
||||
//success login
|
||||
localStorage.setItem("token", loginResult.data.token);
|
||||
localStorage.setItem("user_id", loginResult.data.user_id);
|
||||
this.$router.push({ path: "/s/search" });
|
||||
} else {
|
||||
this.showErrorMessage = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.showErrorMessage = true;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user