fix: removed login page and redirect to frappe's login page
This commit is contained in:
parent
455c6963a8
commit
1cafab1fda
@ -1,104 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="flex h-screen w-screen justify-center bg-gray-100">
|
|
||||||
<div class="mt-32 w-full px-4">
|
|
||||||
<CRMLogo class="mx-auto h-10" />
|
|
||||||
<div class="mt-6 flex items-center justify-center space-x-1.5">
|
|
||||||
<span class="text-3xl font-semibold text-gray-900">Login to CRM</span>
|
|
||||||
</div>
|
|
||||||
<div class="mx-auto mt-6 w-full px-4 sm:w-96">
|
|
||||||
<form
|
|
||||||
v-if="showEmailLogin"
|
|
||||||
method="POST"
|
|
||||||
action="/api/method/login"
|
|
||||||
@submit.prevent="submit"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<FormControl
|
|
||||||
variant="outline"
|
|
||||||
size="md"
|
|
||||||
:type="
|
|
||||||
(email || '').toLowerCase() === 'administrator'
|
|
||||||
? 'text'
|
|
||||||
: 'email'
|
|
||||||
"
|
|
||||||
label="Email"
|
|
||||||
v-model="email"
|
|
||||||
placeholder="jane@example.com"
|
|
||||||
:disabled="session.login.loading"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mt-4">
|
|
||||||
<FormControl
|
|
||||||
variant="outline"
|
|
||||||
size="md"
|
|
||||||
label="Password"
|
|
||||||
v-model="password"
|
|
||||||
placeholder="••••••"
|
|
||||||
:disabled="session.login.loading"
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<ErrorMessage class="mt-2" :message="session.login.error" />
|
|
||||||
<Button
|
|
||||||
variant="solid"
|
|
||||||
class="mt-6 w-full"
|
|
||||||
:loading="session.login.loading"
|
|
||||||
>
|
|
||||||
Login
|
|
||||||
</Button>
|
|
||||||
<button
|
|
||||||
v-if="authProviders.data.length"
|
|
||||||
class="mt-2 w-full py-2 text-base text-gray-600"
|
|
||||||
@click="showEmailLogin = false"
|
|
||||||
>
|
|
||||||
Login using other methods
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
<div
|
|
||||||
class="mx-auto space-y-2"
|
|
||||||
v-if="authProviders.data && !showEmailLogin"
|
|
||||||
>
|
|
||||||
<Button @click="showEmailLogin = true" variant="solid" class="w-full">
|
|
||||||
Login via email
|
|
||||||
</Button>
|
|
||||||
<a
|
|
||||||
class="flex justify-center items-center gap-2 w-full rounded border bg-gray-900 px-3 py-1 text-center text-base h-7 focus:outline-none focus:ring-2 focus:ring-gray-400 text-white transition-colors hover:bg-gray-700"
|
|
||||||
v-for="provider in authProviders.data"
|
|
||||||
:key="provider.name"
|
|
||||||
:href="provider.auth_url"
|
|
||||||
>
|
|
||||||
<div v-if="provider.icon" v-html="provider.icon" />
|
|
||||||
Login via {{ provider.provider_name }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script setup>
|
|
||||||
import CRMLogo from '@/components/Icons/CRMLogo.vue';
|
|
||||||
import { sessionStore } from '@/stores/session'
|
|
||||||
import { createResource } from 'frappe-ui'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
|
|
||||||
const session = sessionStore()
|
|
||||||
let showEmailLogin = ref(false)
|
|
||||||
let email = ref('')
|
|
||||||
let password = ref('')
|
|
||||||
|
|
||||||
let authProviders = createResource({
|
|
||||||
url: 'crm.api.auth.oauth_providers',
|
|
||||||
auto: true,
|
|
||||||
onSuccess(data) {
|
|
||||||
showEmailLogin.value = data.length === 0
|
|
||||||
},
|
|
||||||
})
|
|
||||||
authProviders.fetch()
|
|
||||||
|
|
||||||
function submit() {
|
|
||||||
session.login.submit({
|
|
||||||
usr: email.value,
|
|
||||||
pwd: password.value,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@ -102,11 +102,6 @@ const routes = [
|
|||||||
name: 'Invalid Page',
|
name: 'Invalid Page',
|
||||||
component: () => import('@/pages/InvalidPage.vue'),
|
component: () => import('@/pages/InvalidPage.vue'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/login',
|
|
||||||
name: 'Login',
|
|
||||||
component: () => import('@/pages/Login.vue'),
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const handleMobileView = (componentName) => {
|
const handleMobileView = (componentName) => {
|
||||||
@ -150,8 +145,9 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
|
|
||||||
if (to.name === 'Login' && isLoggedIn) {
|
if (to.name === 'Login' && isLoggedIn) {
|
||||||
next({ name: 'Leads' })
|
next({ name: 'Leads' })
|
||||||
} else if (to.name !== 'Login' && !isLoggedIn) {
|
} else if (!isLoggedIn) {
|
||||||
next({ name: 'Login' })
|
users?.reset?.()
|
||||||
|
window.location.href = "/login?redirect-to=/crm";
|
||||||
} else if (to.matched.length === 0) {
|
} else if (to.matched.length === 0) {
|
||||||
next({ name: 'Invalid Page' })
|
next({ name: 'Invalid Page' })
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -35,7 +35,6 @@ export const sessionStore = defineStore('crm-session', () => {
|
|||||||
const logout = createResource({
|
const logout = createResource({
|
||||||
url: 'logout',
|
url: 'logout',
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
users.reset()
|
|
||||||
user.value = null
|
user.value = null
|
||||||
router.replace({ name: 'Login' })
|
router.replace({ name: 'Login' })
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user