mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-06 12:27:44 +00:00
docs: wrong phone number api
This commit is contained in:
@@ -89,6 +89,36 @@ export const auth = betterAuth({
|
||||
passkey(),
|
||||
bearer(),
|
||||
admin(),
|
||||
{
|
||||
id: "last-login-ip",
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
matcher(context) {
|
||||
return true;
|
||||
},
|
||||
async handler(ctx) {
|
||||
const header = ctx.headers;
|
||||
const response = ctx.context.returned;
|
||||
if (response instanceof Response) {
|
||||
const hasSetCookie = response.headers.get("set-cookie");
|
||||
const hasSessionCookie = response.headers
|
||||
.get("set-cookie")
|
||||
?.includes("session_token");
|
||||
if (hasSessionCookie) {
|
||||
const ipAddress =
|
||||
header?.get("x-forwarded-for") ||
|
||||
header?.get("cf-connecting-ip");
|
||||
if (ipAddress) {
|
||||
//update the user's last login IP
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
socialProviders: {
|
||||
github: {
|
||||
|
||||
Reference in New Issue
Block a user