signin and signup

This commit is contained in:
artem 2024-05-01 11:56:53 +03:00
parent 28bc7888ce
commit c1fad4a632
5 changed files with 22 additions and 8 deletions

View File

@ -17,7 +17,7 @@
/>
<link rel="icon" href="/favicon.ico" />
<title>Vuestic Admin</title>
<title>Cycle Rider Ala Strava for Russian/Belorussian</title>
</head>
<body>
<div id="app"></div>

View File

@ -1,5 +1,5 @@
{
"name": "vuestic-admin",
"name": "cycle-rider",
"private": true,
"version": "3.1.0",
"scripts": {

View File

@ -14,7 +14,7 @@ app.use(stores);
app.use(router);
app.use(i18n);
app.use(createVuestic({ config: vuesticGlobalConfig }));
app.provide('HOST', "https://cycle-rider.ru");
if (import.meta.env.VITE_APP_GTM_ENABLED) {
app.use(
createGtm({

View File

@ -60,6 +60,8 @@
</template>
<script lang="ts" setup>
import { inject } from 'vue'
import axios from "axios";
import { reactive } from "vue";
import { useRouter } from "vue-router";
@ -69,22 +71,27 @@ import { validators } from "../../services/utils";
const { validate } = useForm("form");
const { push } = useRouter();
const { init } = useToast();
const HOST = inject('HOST');
const formData = reactive({
email: "",
password: "",
keepLoggedIn: false,
});
const token = localStorage.getItem("token");
if (token != undefined && token.length > 0) {
push({ name: "dashboard" }).catch((error) => {});
}
const submit = () => {
if (validate()) {
axios
.post("http://localhost:3000/api/v0/signin", {
.post(`${HOST}/api/v0/signin`, {
login: formData.email,
password: formData.password,
})
.then((response) => {
// TODO: save token
localStorage.setItem('token', response.data.token);
init({ message: "Вы успешно вошли!", color: "success" });
push({ name: "dashboard" });
})

View File

@ -73,6 +73,7 @@
</template>
<script lang="ts" setup>
import { inject } from 'vue'
import axios from "axios";
import { reactive } from "vue";
import { useRouter } from "vue-router";
@ -81,6 +82,7 @@ import { useForm, useToast } from "vuestic-ui";
const { validate } = useForm("form");
const { push } = useRouter();
const { init } = useToast();
const HOST = inject('HOST');
const formData = reactive({
email: "",
@ -88,15 +90,20 @@ const formData = reactive({
repeatPassword: "",
});
const token = localStorage.getItem("token");
if (token != undefined && token.length > 0) {
push({ name: "dashboard" }).catch((error) => {});
}
const submit = () => {
if (validate()) {
axios
.post("http://localhost:3000/api/v0/signin", {
.post(`${HOST}/api/v0/signup`, {
email: formData.email,
password: formData.password,
})
.then((response) => {
// TODO: save token
localStorage.setItem('token', response.data.token);
init({
message: "Вы успешно вошли",
color: "success",