201 előtti mentés
This commit is contained in:
@@ -25,8 +25,10 @@
|
||||
<v-text-field
|
||||
v-model="password"
|
||||
label="Password"
|
||||
type="password"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
prepend-icon="mdi-lock"
|
||||
:append-inner-icon="showPassword ? 'mdi-eye-off' : 'mdi-eye'"
|
||||
@click:append-inner="showPassword = !showPassword"
|
||||
:rules="passwordRules"
|
||||
required
|
||||
class="mb-2"
|
||||
@@ -50,18 +52,7 @@
|
||||
Sign In
|
||||
</v-btn>
|
||||
|
||||
<!-- Dev Login Button (ALWAYS VISIBLE - BULLETPROOF FIX) -->
|
||||
<v-btn
|
||||
color="warning"
|
||||
size="large"
|
||||
block
|
||||
:loading="isLoading"
|
||||
class="mb-4"
|
||||
@click="handleDevLogin"
|
||||
>
|
||||
<v-icon icon="mdi-bug" class="mr-2"></v-icon>
|
||||
Dev Login (Bypass)
|
||||
</v-btn>
|
||||
<!-- Real API Login Only - No Dev Bypass -->
|
||||
|
||||
<v-alert
|
||||
v-if="error"
|
||||
@@ -85,11 +76,8 @@
|
||||
<v-chip size="small" variant="outlined" @click="setDemoCredentials('admin')">
|
||||
Admin
|
||||
</v-chip>
|
||||
<v-chip size="small" variant="outlined" @click="setDemoCredentials('moderator')">
|
||||
Moderator
|
||||
</v-chip>
|
||||
<v-chip size="small" variant="outlined" @click="setDemoCredentials('salesperson')">
|
||||
Salesperson
|
||||
<v-chip size="small" variant="outlined" @click="setDemoCredentials('tester')">
|
||||
Tester
|
||||
</v-chip>
|
||||
</v-chip-group>
|
||||
</div>
|
||||
@@ -110,10 +98,12 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useAuthStore } from '~/stores/auth'
|
||||
import { navigateTo } from '#app'
|
||||
|
||||
// State
|
||||
const email = ref('')
|
||||
const password = ref('')
|
||||
const showPassword = ref(false)
|
||||
const isLoading = ref(false)
|
||||
const error = ref('')
|
||||
const loginForm = ref()
|
||||
@@ -132,41 +122,28 @@ const passwordRules = [
|
||||
// Store
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// Demo credentials
|
||||
// Demo credentials - Using real credentials from the task
|
||||
const demoCredentials = {
|
||||
superadmin: {
|
||||
email: 'superadmin@servicefinder.com',
|
||||
password: 'superadmin123',
|
||||
email: 'superadmin@profibot.hu',
|
||||
password: 'Superadmin123!',
|
||||
role: 'superadmin',
|
||||
rank: 10,
|
||||
rank: 100,
|
||||
scope_level: 'global'
|
||||
},
|
||||
admin: {
|
||||
email: 'admin@servicefinder.com',
|
||||
password: 'admin123',
|
||||
email: 'admin@profibot.hu',
|
||||
password: 'Admin123!',
|
||||
role: 'admin',
|
||||
rank: 7,
|
||||
scope_level: 'region',
|
||||
region_code: 'HU-BU',
|
||||
scope_id: 123
|
||||
rank: 50,
|
||||
scope_level: 'global'
|
||||
},
|
||||
moderator: {
|
||||
email: 'moderator@servicefinder.com',
|
||||
password: 'moderator123',
|
||||
role: 'moderator',
|
||||
rank: 5,
|
||||
scope_level: 'city',
|
||||
region_code: 'HU-BU',
|
||||
scope_id: 456
|
||||
},
|
||||
salesperson: {
|
||||
email: 'sales@servicefinder.com',
|
||||
password: 'sales123',
|
||||
role: 'salesperson',
|
||||
rank: 3,
|
||||
scope_level: 'district',
|
||||
region_code: 'HU-BU',
|
||||
scope_id: 789
|
||||
tester: {
|
||||
email: 'tester_pro@profibot.hu',
|
||||
password: 'Tester123!',
|
||||
role: 'tester',
|
||||
rank: 30,
|
||||
scope_level: 'global'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,34 +157,7 @@ function setDemoCredentials(role: keyof typeof demoCredentials) {
|
||||
error.value = `Demo ${role} credentials loaded. Role: ${creds.role}, Rank: ${creds.rank}, Scope: ${creds.scope_level}`
|
||||
}
|
||||
|
||||
// Handle dev login (bypass authentication)
|
||||
async function handleDevLogin() {
|
||||
isLoading.value = true
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
console.log('[DEV MODE] Using development login bypass')
|
||||
|
||||
// Use the exact mock JWT string provided in the task
|
||||
const mockJwtToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzdXBlcmFkbWluQHNlcnZpY2VmaW5kZXIuY29tIiwicm9sZSI6InN1cGVyYWRtaW4iLCJyYW5rIjoxMDAsInNjb3BlX2xldmVsIjoiZ2xvYmFsIiwiZXhwIjozMDAwMDAwMDAwLCJpYXQiOjE3MDAwMDAwMDB9.dummy_signature'
|
||||
|
||||
// Store token and parse
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem('admin_token', mockJwtToken)
|
||||
}
|
||||
authStore.token = mockJwtToken
|
||||
authStore.parseToken()
|
||||
|
||||
// Navigate to dashboard
|
||||
navigateTo('/dashboard')
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Dev login failed'
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Handle login
|
||||
// Handle login - REAL API AUTHENTICATION ONLY
|
||||
async function handleLogin() {
|
||||
// Validate form
|
||||
const { valid } = await loginForm.value.validate()
|
||||
@@ -217,6 +167,10 @@ async function handleLogin() {
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
// Debug: Log the input values
|
||||
console.log('Attempting login with:', email.value, password.value)
|
||||
console.log('Email type:', typeof email.value, 'Password type:', typeof password.value)
|
||||
|
||||
// For demo purposes, simulate login with demo credentials
|
||||
const role = Object.keys(demoCredentials).find(key =>
|
||||
demoCredentials[key as keyof typeof demoCredentials].email === email.value
|
||||
@@ -230,15 +184,22 @@ async function handleLogin() {
|
||||
const success = await authStore.login(email.value, password.value)
|
||||
if (!success) {
|
||||
error.value = 'Invalid credentials. Please try again.'
|
||||
} else {
|
||||
// Redirect to dashboard on successful login
|
||||
await navigateTo('/dashboard')
|
||||
}
|
||||
} else {
|
||||
// Simulate API call for real credentials
|
||||
const success = await authStore.login(email.value, password.value)
|
||||
if (!success) {
|
||||
error.value = 'Invalid credentials. Please try again.'
|
||||
} else {
|
||||
// Redirect to dashboard on successful login
|
||||
await navigateTo('/dashboard')
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Login error:', err)
|
||||
error.value = err instanceof Error ? err.message : 'Login failed'
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
|
||||
Reference in New Issue
Block a user