Almost complete org/permission handling. Much cleanup, bootstrap works.
This commit is contained in:
@@ -11,11 +11,6 @@
|
||||
{{ authStore.isLoading ? 'Authenticating...' : 'Login with Your Device' }}
|
||||
</button>
|
||||
</form>
|
||||
<p class="toggle-link">
|
||||
<a href="#" @click.prevent="authStore.currentView = 'register'">
|
||||
Don't have an account? Register here
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { formatDate } from '@/utils/helpers'
|
||||
import { registerCredential } from '@/utils/passkey'
|
||||
import passkey from '@/utils/passkey'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const updateInterval = ref(null)
|
||||
@@ -119,7 +119,7 @@ const addNewCredential = async () => {
|
||||
try {
|
||||
authStore.isLoading = true
|
||||
authStore.showMessage('Adding new passkey...', 'info')
|
||||
const result = await registerCredential()
|
||||
await passkey.register()
|
||||
await authStore.loadUserInfo()
|
||||
authStore.showMessage('New passkey added successfully!', 'success', 3000)
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="view active">
|
||||
<h1>🔐 Create Account</h1>
|
||||
<form @submit.prevent="handleRegister">
|
||||
<input
|
||||
type="text"
|
||||
v-model="user_name"
|
||||
placeholder="Enter username"
|
||||
required
|
||||
:disabled="authStore.isLoading"
|
||||
>
|
||||
<button
|
||||
type="submit"
|
||||
class="btn-primary"
|
||||
:disabled="authStore.isLoading || !user_name.trim()"
|
||||
>
|
||||
{{ authStore.isLoading ? 'Registering...' : 'Register Passkey' }}
|
||||
</button>
|
||||
</form>
|
||||
<p class="toggle-link">
|
||||
<a href="#" @click.prevent="authStore.currentView = 'login'">
|
||||
Already have an account? Login here
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const user_name = ref('')
|
||||
|
||||
const handleRegister = async () => {
|
||||
if (!user_name.value.trim()) return
|
||||
|
||||
try {
|
||||
authStore.showMessage('Starting registration...', 'info')
|
||||
await authStore.register(user_name.value.trim())
|
||||
authStore.showMessage('Passkey registered successfully!', 'success', 2000)
|
||||
|
||||
setTimeout(() => {
|
||||
authStore.currentView = 'profile'
|
||||
}, 1500)
|
||||
} catch (error) {
|
||||
console.error('Registration error:', error)
|
||||
if (error.name === "NotAllowedError") {
|
||||
authStore.showMessage('Registration cancelled', 'error')
|
||||
} else {
|
||||
authStore.showMessage(`Registration failed: ${error.message}`, 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -3,6 +3,7 @@
|
||||
<div class="view active">
|
||||
<h1>🔑 Add New Credential</h1>
|
||||
<h3>👤 {{ authStore.userInfo?.user?.user_name }}</h3>
|
||||
<!-- TODO: allow editing name <input type="text" v-model="user_name" required :disabled="authStore.isLoading"> -->
|
||||
<p>Proceed to complete {{authStore.userInfo?.session_type}}:</p>
|
||||
<button
|
||||
class="btn-primary"
|
||||
@@ -17,7 +18,7 @@
|
||||
|
||||
<script setup>
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { registerCredential } from '@/utils/passkey'
|
||||
import passkey from '@/utils/passkey'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
@@ -26,8 +27,7 @@ async function register() {
|
||||
authStore.showMessage('Starting registration...', 'info')
|
||||
|
||||
try {
|
||||
// TODO: For reset sessions, might use registerWithToken() in the future
|
||||
const result = await registerCredential()
|
||||
const result = await passkey.register()
|
||||
console.log("Result", result)
|
||||
await authStore.setSessionCookie(result.session_token)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user