signin and signup
This commit is contained in:
parent
28bc7888ce
commit
c1fad4a632
|
|
@ -17,7 +17,7 @@
|
||||||
/>
|
/>
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
|
||||||
<title>Vuestic Admin</title>
|
<title>Cycle Rider Ala Strava for Russian/Belorussian</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "vuestic-admin",
|
"name": "cycle-rider",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ app.use(stores);
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
app.use(createVuestic({ config: vuesticGlobalConfig }));
|
app.use(createVuestic({ config: vuesticGlobalConfig }));
|
||||||
|
app.provide('HOST', "https://cycle-rider.ru");
|
||||||
if (import.meta.env.VITE_APP_GTM_ENABLED) {
|
if (import.meta.env.VITE_APP_GTM_ENABLED) {
|
||||||
app.use(
|
app.use(
|
||||||
createGtm({
|
createGtm({
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { inject } from 'vue'
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
@ -69,22 +71,27 @@ import { validators } from "../../services/utils";
|
||||||
const { validate } = useForm("form");
|
const { validate } = useForm("form");
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const { init } = useToast();
|
const { init } = useToast();
|
||||||
|
const HOST = inject('HOST');
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
keepLoggedIn: false,
|
keepLoggedIn: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const token = localStorage.getItem("token");
|
||||||
|
if (token != undefined && token.length > 0) {
|
||||||
|
push({ name: "dashboard" }).catch((error) => {});
|
||||||
|
}
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
if (validate()) {
|
if (validate()) {
|
||||||
axios
|
axios
|
||||||
.post("http://localhost:3000/api/v0/signin", {
|
.post(`${HOST}/api/v0/signin`, {
|
||||||
login: formData.email,
|
login: formData.email,
|
||||||
password: formData.password,
|
password: formData.password,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// TODO: save token
|
localStorage.setItem('token', response.data.token);
|
||||||
init({ message: "Вы успешно вошли!", color: "success" });
|
init({ message: "Вы успешно вошли!", color: "success" });
|
||||||
push({ name: "dashboard" });
|
push({ name: "dashboard" });
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { inject } from 'vue'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
@ -81,6 +82,7 @@ import { useForm, useToast } from "vuestic-ui";
|
||||||
const { validate } = useForm("form");
|
const { validate } = useForm("form");
|
||||||
const { push } = useRouter();
|
const { push } = useRouter();
|
||||||
const { init } = useToast();
|
const { init } = useToast();
|
||||||
|
const HOST = inject('HOST');
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
email: "",
|
email: "",
|
||||||
|
|
@ -88,15 +90,20 @@ const formData = reactive({
|
||||||
repeatPassword: "",
|
repeatPassword: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const token = localStorage.getItem("token");
|
||||||
|
if (token != undefined && token.length > 0) {
|
||||||
|
push({ name: "dashboard" }).catch((error) => {});
|
||||||
|
}
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
if (validate()) {
|
if (validate()) {
|
||||||
axios
|
axios
|
||||||
.post("http://localhost:3000/api/v0/signin", {
|
.post(`${HOST}/api/v0/signup`, {
|
||||||
email: formData.email,
|
email: formData.email,
|
||||||
password: formData.password,
|
password: formData.password,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// TODO: save token
|
localStorage.setItem('token', response.data.token);
|
||||||
init({
|
init({
|
||||||
message: "Вы успешно вошли",
|
message: "Вы успешно вошли",
|
||||||
color: "success",
|
color: "success",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue