mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
token request
This commit is contained in:
parent
20379340a2
commit
26d040a6b1
4 changed files with 50 additions and 5 deletions
|
@ -7,6 +7,7 @@ import migration from "./migration";
|
||||||
import myUtils from "./upload";
|
import myUtils from "./upload";
|
||||||
import category from "./category";
|
import category from "./category";
|
||||||
import meta from "./meta";
|
import meta from "./meta";
|
||||||
|
import users from "./users"
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -19,4 +20,5 @@ export default {
|
||||||
utils: myUtils,
|
utils: myUtils,
|
||||||
categories: category,
|
categories: category,
|
||||||
meta: meta,
|
meta: meta,
|
||||||
|
users: users
|
||||||
};
|
};
|
||||||
|
|
23
frontend/src/api/users.js
Normal file
23
frontend/src/api/users.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { baseURL } from "./api-utils";
|
||||||
|
import { apiReq } from "./api-utils";
|
||||||
|
const authPrefix = baseURL + "auth/";
|
||||||
|
|
||||||
|
const authURLs = {
|
||||||
|
token: `${authPrefix}token`,
|
||||||
|
};
|
||||||
|
|
||||||
|
// const usersURLs = {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
export default {
|
||||||
|
async login(formData) {
|
||||||
|
let response = await apiReq.post(authURLs.token, formData, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
};
|
|
@ -32,7 +32,9 @@
|
||||||
light="light"
|
light="light"
|
||||||
prepend-icon="mdi-lock"
|
prepend-icon="mdi-lock"
|
||||||
:label="$t('login.password')"
|
:label="$t('login.password')"
|
||||||
type="password"
|
:type="showPassword ? 'text' : 'password'"
|
||||||
|
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
||||||
|
@click:append="showPassword = !showPassword"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
class="mb-2 mt-0"
|
class="mb-2 mt-0"
|
||||||
|
@ -84,6 +86,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showLogin: false,
|
showLogin: false,
|
||||||
|
showPassword: false,
|
||||||
user: {
|
user: {
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
|
@ -98,7 +101,10 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async login() {
|
async login() {
|
||||||
let key = await api.login(this.user.email, this.user.password);
|
let formData = new FormData();
|
||||||
|
formData.append("username", this.user.email);
|
||||||
|
formData.append("password", this.user.password);
|
||||||
|
let key = await api.users.login(formData);
|
||||||
console.log(key);
|
console.log(key);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,10 +2,19 @@
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<v-dialog v-model="addRecipe" width="650" @click:outside="reset">
|
<v-dialog v-model="addRecipe" width="650" @click:outside="reset">
|
||||||
<v-card :loading="processing">
|
<v-card :loading="processing">
|
||||||
<v-app-bar dark color="primary mb-2">
|
<v-app-bar dark color="primary mb-2">
|
||||||
<v-icon large left>
|
<v-icon large left v-if="!processing">
|
||||||
mdi-link
|
mdi-link
|
||||||
</v-icon>
|
</v-icon>
|
||||||
|
<v-progress-circular
|
||||||
|
v-else
|
||||||
|
indeterminate
|
||||||
|
color="white"
|
||||||
|
large
|
||||||
|
class="mr-2"
|
||||||
|
>
|
||||||
|
</v-progress-circular>
|
||||||
|
|
||||||
<v-toolbar-title class="headline">
|
<v-toolbar-title class="headline">
|
||||||
{{ $t("new-recipe.from-url") }}
|
{{ $t("new-recipe.from-url") }}
|
||||||
</v-toolbar-title>
|
</v-toolbar-title>
|
||||||
|
@ -40,7 +49,12 @@
|
||||||
<v-btn color="grey" text @click="reset">
|
<v-btn color="grey" text @click="reset">
|
||||||
{{ $t("general.close") }}
|
{{ $t("general.close") }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn color="success" text @click="createRecipe">
|
<v-btn
|
||||||
|
color="success"
|
||||||
|
text
|
||||||
|
@click="createRecipe"
|
||||||
|
:loading="processing"
|
||||||
|
>
|
||||||
{{ $t("general.submit") }}
|
{{ $t("general.submit") }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue