attemptingLogin.via
Massimo Melina committed
Sep 18, 2024 at 22:18 UTC
50384f4aa2c9a8e1afa915e808a9417b921760b9
1 file changed
+4
-4
src/middlewares.ts
+4
-4
@@ -112,7 +112,7 @@ export const prepareState: Koa.Middleware = async (ctx, next) => {
112
if (!login) return
113
const [u, p] = splitAt(':', String(login))
114
ctx.redirect(ctx.originalUrl.slice(0, -ctx.querystring.length-1)) // redirect to hide credentials
115
- return doLogin(u, p)
115
+ return doLogin(u, p, 'url')
116
}
117
118
function getHttpAccount() {
@@ -120,14 +120,14 @@ export const prepareState: Koa.Middleware = async (ctx, next) => {
120
if (!b64) return
121
try {
122
const [u, p] = atob(b64).split(':')
123
- return doLogin(u!, p||'')
123
+ return doLogin(u!, p||'', 'header')
124
}
125
catch {}
126
}
127
128
- async function doLogin(u: string, p: string) {
128
+ async function doLogin(u: string, p: string, via: string) {
129
if (!u || u === ctx.session?.username) return // providing credentials, but not needed
130
- await events.emitAsync('attemptingLogin', { ctx, username: u })
130
+ await events.emitAsync('attemptingLogin', { ctx, username: u, via })
131
const a = await srpCheck(u, p)
132
if (a) {
133
await setLoggedIn(ctx, a.username)