mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
bearer-auth: add to middleware:getAccount
This commit is contained in:
parent
1dfd095563
commit
64dd66dc03
|
@ -3,7 +3,11 @@ import express, { type RequestHandler } from "express"
|
||||||
import ServeError from "../lib/errors";
|
import ServeError from "../lib/errors";
|
||||||
|
|
||||||
export let getAccount: RequestHandler = function(req, res, next) {
|
export let getAccount: RequestHandler = function(req, res, next) {
|
||||||
res.locals.acc = Accounts.getFromToken(req.cookies.auth)
|
res.locals.acc = Accounts.getFromToken(req.cookies.auth || (
|
||||||
|
req.header("authorization")?.startsWith("Bearer ")
|
||||||
|
? req.header("authorization")?.split(" ")[1]
|
||||||
|
: undefined
|
||||||
|
))
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue