Altera login, add cookie e comeca lista de videos
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<q-layout view="hHh lpr fFf">
|
||||
<q-layout view="hHh LpR fFf">
|
||||
<q-drawer
|
||||
v-model="leftDrawerOpen"
|
||||
show-if-above
|
||||
@@ -78,6 +78,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Cookies from "js-cookie";
|
||||
import Button from "@components/Button";
|
||||
import { API } from "@config/axios";
|
||||
|
||||
@@ -106,18 +107,26 @@ export default {
|
||||
try {
|
||||
this.loading = true;
|
||||
|
||||
const form = new FormData();
|
||||
const params = new URLSearchParams();
|
||||
|
||||
form.append("username", this.username);
|
||||
form.append("password", this.password);
|
||||
params.append("username", this.username);
|
||||
params.append("password", this.password);
|
||||
|
||||
const { data } = API.post("/auth/login", form, {
|
||||
const { data } = await API.post("/auth/login", params.toString(), {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
Cookies.set("token", data.access_token, {
|
||||
expires: data.expires_in,
|
||||
});
|
||||
|
||||
Cookies.set("refresh_token", data.refresh_token, {
|
||||
expires: data.refresh_expires_in,
|
||||
});
|
||||
|
||||
await this.$router.push("/");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user