Closed WildEgo closed 2 years ago
I actually have some plans to create Typescript declarations, as it would be soooo helpful.
Currently, there's a little example in the docs about authentication. It needs more work, but I guess it's useful.
I actually have some plans to create Typescript declarations, as it would be soooo helpful.
Currently, there's a little example in the docs about authentication. It needs more work, but I guess it's useful.
I'll give it a look, I have some structure kinda done but not really sure if it works or not, atm it's just kind of a preview, if you want to check if the auth flow makes sense or not here's the repo.
It's correct, the flow is:
lightdm.authenticate(user)
lightdm.respond(password)
lightdm.start_session(session)
However, it won't work. LightDM has a "delay" between those tasks, so if you do provide a response immediately after the authenticate, LightDM will throw an error (not dangerous, but the theme won't work).
You have multiple options...
Just add a delay, just as simple like that.
In the docs, I have something like this to add a delay:
async function wait(ms) {
return new Promise((resolve) => {
setTimeout(() => resolve(), ms);
});
}
// Inside async function
lightdm.authenticate("user");
await wait(100);
lightdm.respond("password");
lightdm.start_session("session");
You can use the provided signals:
lightdm.show_prompt
to provide the password automatically.lightdm.authentication_complete
to start_session automatically.So, you could have something like this:
lightdm.show_prompt.connect((text, type) => {
lightdm.respond("password");
})
lightdm.authentication_complete.connect(() => {
lightdm.start_session("session");
})
lightdm.authenticate("user");
// Everything is handled by signals from here
Let the user select their user to authenticate, and run lightdm.authenticate(user)
.
Then, they will provide the password, and run lightdm.respond(password)
.
And so, the user clicks on something to start the session, and run lightdm.start_session(session)
.
It's correct, the flow is:
- Authenticate:
lightdm.authenticate(user)
- Provide password or respond:
lightdm.respond(password)
- Start session:
lightdm.start_session(session)
However, it won't work. LightDM has a "delay" between those tasks, so if you do provide a responde immediately after the authenticate, LightDM will throw an error (not dangerous, but the theme won't work).
You have multiple options...
Add the delay
Just add a delay, just as simple like that.
In the docs, I have something like this to add a delay:
async function wait(ms) { return new Promise((resolve) => { setTimeout(() => resolve(), ms); }); } // Inside async function lightdm.authenticate("user"); await wait(100); lightdm.respond("password"); lightdm.start_session("session");
Work with signals
You can use the provided signals:
lightdm.show_prompt
to provide the password automatically.lightdm.authentication_complete
to start_session automatically.So, you could have something like this:
lightdm.show_prompt.connect((text, type) => { lightdm.respond("password"); }) lightdm.authentication_complete.connect(() => { lightdm.start_session("session"); }) lightdm.authenticate("user"); // Everything is handled by signals from here
Do it "programmatically"
Let the user select their user to authenticate, and run
lightdm.authenticate(user)
.Then, they will provide the password, and run
lightdm.respond(password)
.And so, the user clicks on something to start the session, and run
lightdm.start_session(session)
.
I'll implement that, it's sad it doesn't run in a true async, it'd be smoother but as long as I get to make my own design I'm happy!
I just created a npm package for nody-greeter/web-greeter typescript types: https://github.com/JezerM/nody-greeter-types
Environment
Description of feature
I'm working on a small theme and I'm using typescript, I've found a Typescript declaration for lightdm-webkit2 (https://github.com/barskern/lightdm-webkit2-typescript/) but it doesn't seem very compatible so I wonder if there are any plans to provide one, would be incredibly useful.
Edit: Also a good example of the flow I should use for the authentication would be highly appreciated since the current themes seem to be a little weird on how they work.