Fix wrong login state

masks
Warinyourself 4 years ago
parent 262128356c
commit 1024118066

@ -15,7 +15,7 @@ export default class MainApp extends Vue {
}
initKeybinds() {
const modKey = 'fn'
const modKey = 'ctrl'
Mousetrap.bind(`${modKey}+t`, () => {
PageModule.openTab({ type: 'themes' })

@ -73,7 +73,6 @@ export default class LoginComponent extends Vue {
<div class={ `login-view login-view--${PageModule.loginPosition}` }>
<AppIcon name={ this.currentDesktop?.key } class='desktop-icon'/>
<AppIcon name={ AppModule.currentOs } class='system-icon'/>
{/* nativeOn */}
<UserAvatar />
<UserInput />
</div>

@ -2,13 +2,12 @@
export interface ExpandedWindow {
lightdm: Lightdm;
authentication_complete(): void;
lightdm_login(
lightdmLogin(
username: string,
password: string,
callback: () => void,
errorCallback: (error: string) => void
): void;
lightdm_start(desktop: string): void;
lightdmStart(desktop: string): void;
show_prompt(text: string, type?: any): void;
show_message(text: string, type: any): void;
}
@ -26,6 +25,7 @@ export interface Lightdm {
languages: LightdmLanguage[];
language: string;
start_authentication(username: string): void;
authenticate(username: string): void;
cancel_authentication(): void;
respond(password: string): void;
login(user: string, session: string): void;
@ -49,7 +49,7 @@ export interface LightdmLanguage {
export interface LightdmSession {
name: string;
key: string;
comment: string;
comment?: string;
}
export const appWindow = (window as unknown) as Window & ExpandedWindow

@ -202,26 +202,8 @@ class App extends VuexModule implements AppState {
@Action
login() {
console.log('Start login')
appWindow.lightdm_login(this.username, this.password, () => {
console.log('FINISH LOGIN?!')
appWindow.lightdm_start(this.currentDesktop?.key || appWindow?.lightdm?.sessions[0].key || 'i3')
}, (error) => {
console.log(`error AUTH ${error}`)
const inputNode = document.getElementById('password')
if (!inputNode) return
inputNode.classList.add('password-input--error')
if (inputErrorTimer) {
clearTimeout(inputErrorTimer)
}
// inputErrorTimer = setTimeout(() => {
// inputNode.classList.remove('password-input--error')
// inputErrorTimer = null
// }, 10000)
appWindow.lightdmLogin(this.username, this.password, () => {
appWindow.lightdmStart(this.currentDesktop?.key || appWindow?.lightdm?.sessions[0].key || 'i3')
})
}

@ -162,20 +162,18 @@
.user-input .password-input--error
border-color red
//animation errorInput .2s 10!important
animation errorInput .3s linear 2
stepBounce = 2px
stepBounce = 5px
@keyframes errorInput
0%
border-color red
transform translateX(0)
25%
border-color red
transform translateX(stepBounce)
transform translateX(-(stepBounce))
75%
border-color red
transform translateX(-stepBounce)
transform translateX(stepBounce)
100%
border-color var(--color-unfocus)
transform translateX(0%)
transform translateX(0)

@ -1,17 +1,13 @@
/* eslint-disable @typescript-eslint/camelcase */
import { appWindow } from '@/models/lightdm'
const DEBUG_PASSWORD = 'password'
const DEBUG_PASSWORD = '1'
const lightdmDebug = appWindow.lightdm === undefined
let password: string
let completeCallback: undefined | Function
if (lightdmDebug) {
// window.greeter_config = {
// branding: {
// background_images: 'no where this is live test'
// }
// }
appWindow.lightdm = {
is_authenticated: false,
authentication_user: undefined,
@ -20,75 +16,38 @@ if (lightdmDebug) {
can_restart: true,
can_hibernate: true,
can_shutdown: true,
// sessions: [
// {
// name: 'i3wm',
// key: 'i3'
// },
// {
// name: 'KDE 5',
// key: 'plasma-shell'
// },
// {
// name: 'Kodi',
// key: 'kodi'
// },
// {
// name: 'Gnome 3',
// key: 'gnome-shell'
// },
// {
// name: 'XFCE 4',
// key: 'xfce'
// },
// {
// name: 'Openbox',
// key: 'openbox'
// },
// {
// name: 'Cinnamon',
// key: 'cinnamon'
// },
// {
// name: 'xmonad',
// key: 'xmonad'
// }
// ],
sessions: [
{
name: 'GNOME',
key: 'gnome',
comment: 'This session logs you into GNOME'
name: 'i3wm',
key: 'i3'
},
{
name: 'GNOME',
key: 'gnome',
comment: 'This session logs you into GNOME'
name: 'KDE 5',
key: 'plasma-shell'
},
{
name: 'GNOME on Xorg',
key: 'gnome-xorg',
comment: 'This session logs you into GNOME'
name: 'Kodi',
key: 'kodi'
},
{
name: 'Openbox',
key: 'openbox',
comment: 'Log in using the Openbox window manager (without a session manager)'
name: 'Gnome 3',
key: 'gnome-shell'
},
{
name: 'XFCE 4',
key: 'xfce'
},
{
name: 'awesome',
key: 'awesome',
comment: 'Highly configurable framework window manager'
name: 'Openbox',
key: 'openbox'
},
{
name: 'i3',
key: 'i3',
comment: 'improved dynamic tiling window manager'
name: 'Cinnamon',
key: 'cinnamon'
},
{
name: 'i3 (with debug log)',
key: 'i3-with-shmlog',
comment: 'improved dynamic tiling window manager'
name: 'xmonad',
key: 'xmonad'
}
],
users: [
@ -114,13 +73,19 @@ if (lightdmDebug) {
],
language: 'American English',
start_authentication: (username) => {
console.log(`Starting authenticating : '${username}'`)
console.log(`Starting authenticating here: '${username}'`)
// appWindow.lightdm.cancel_autologin();
// appWindow.lightdm.cancel_authentication()
// appWindow.lightdm.authenticate(String(accounts.getDefaultUserName()))
if (appWindow?.lightdm !== undefined) {
appWindow.lightdm.authentication_user = username
}
// lightdm.is_authenticated = true;
// appWindow.lightdm.authentication_user = username
appWindow.show_prompt('Password: ')
// appWindow.show_prompt('Password: ')
appWindow.lightdm.respond(password)
},
authenticate: (username) => {
console.log(`Starting authenticating user: '${username}'`)
},
cancel_authentication: () => {
console.log('Auth cancelled')
@ -128,19 +93,16 @@ if (lightdmDebug) {
respond: (password) => {
console.log(`Password provided : '${password}'`)
if (password === DEBUG_PASSWORD && appWindow?.lightdm !== undefined) {
if (password === DEBUG_PASSWORD) {
appWindow.lightdm.is_authenticated = true
} else {
const now = new Date().getTime()
while (new Date().getTime() < now + 2000);
}
appWindow.authentication_complete()
},
login: (user, session) => {
login(user, session) {
alert(`Logged with '${user}' (Session: '${session}') !`)
},
shutdown: () => {
shutdown() {
alert('(DEBUG: System is shutting down)')
},
hibernate() {
@ -155,50 +117,52 @@ if (lightdmDebug) {
}
}
let password: string
let globalErrorCallback: undefined | Function
let completeCallback: undefined | Function
appWindow.lightdm_login = (username, pass, callback, errorCallback) => {
appWindow.lightdmLogin = (username, pass, callback) => {
completeCallback = callback
globalErrorCallback = errorCallback
password = pass
console.log(`lightdm_login ${username}, ${pass}`)
console.log(`lightdmLogin ${username}, ${pass}`)
if (appWindow.lightdm) {
appWindow.lightdm.start_authentication(username)
}
appWindow.lightdm.start_authentication(username)
}
appWindow.lightdm_start = desktop => {
appWindow.lightdmStart = desktop => {
if (appWindow.lightdm) {
appWindow.lightdm.login(appWindow.lightdm.authentication_user || '', desktop)
}
}
appWindow.show_prompt = (text, _type) => {
if (text === 'Password: ') {
if (appWindow.lightdm) {
appWindow.lightdm.respond(password)
}
}
}
let inputErrorTimer: null | any
appWindow.authentication_complete = () => {
if (appWindow?.lightdm?.is_authenticated && completeCallback) {
completeCallback()
} else if (appWindow?.lightdm && globalErrorCallback) {
appWindow.lightdm.cancel_authentication()
globalErrorCallback('Invalid username/password')
} else {
alert('SOMETHING WRONG')
appWindow.lightdm.cancel_authentication()
const inputNode = document.getElementById('password')
if (!inputNode) return
inputNode.classList.add('password-input--error')
if (inputErrorTimer) {
clearTimeout(inputErrorTimer)
}
inputErrorTimer = setTimeout(() => {
inputNode.classList.remove('password-input--error')
inputErrorTimer = null
}, 10000)
}
}
appWindow.show_message = (text, type) => {
if (globalErrorCallback) {
globalErrorCallback(text)
} else {
alert('SOMETHING WRONG with show_message')
appWindow.show_prompt = (text, _type) => {
if (text === 'Password: ') {
if (appWindow.lightdm) {
appWindow.lightdm.respond(password)
}
}
}
appWindow.show_message = (text, type) => {
alert(text)
}

@ -1,4 +1,6 @@
#! /bin/bash
dm-tool add-nested-seat --screen 1366x768
# lightdm-webkit2-greeter
# dm-tool switch-to-greeter
# lightdm-webkit2-greeter
# lightdm --test-mode

Loading…
Cancel
Save