mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2025-03-04 08:43:58 +00:00
fix logins
This commit is contained in:
parent
5a1af750d5
commit
3e6a2a4f37
2 changed files with 15 additions and 5 deletions
|
@ -499,8 +499,7 @@ function page_login() {
|
||||||
async function login(event) {
|
async function login(event) {
|
||||||
const values = {
|
const values = {
|
||||||
username: fields.username.value.trim(),
|
username: fields.username.value.trim(),
|
||||||
password: fields.password.value.trim(),
|
password: fields.password.value.trim()
|
||||||
redir: fields.redir.value.trim()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (values.username === "" | values.password === "") {
|
if (values.username === "" | values.password === "") {
|
||||||
|
@ -509,14 +508,16 @@ function page_login() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await request("POST", "v1/login", values);
|
application = await request("POST", "v1/login", values);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast(error);
|
toast(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.location = values.redir;
|
const max_age = 60 * 60 * 24 * 30;
|
||||||
|
document.cookie = `user-token=${application.token};Secure;SameSite=Strict;Domain=${document.location.host};MaxAge=${max_age}`;
|
||||||
|
document.location = fields.redir.value.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,16 @@ async def handle_login(
|
||||||
|
|
||||||
application = s.put_app_login(user)
|
application = s.put_app_login(user)
|
||||||
|
|
||||||
return objects.Application.from_row(application)
|
return objects.Application(
|
||||||
|
application.client_id,
|
||||||
|
application.client_secret,
|
||||||
|
application.name,
|
||||||
|
application.website,
|
||||||
|
application.redirect_uri,
|
||||||
|
application.token,
|
||||||
|
application.created,
|
||||||
|
application.accessed
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@Route(HttpMethod.GET, "/api/v1/app", "Application", True)
|
@Route(HttpMethod.GET, "/api/v1/app", "Application", True)
|
||||||
|
|
Loading…
Reference in a new issue