mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 20:37: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: {
|
||||
|
||||
@@ -92,10 +92,8 @@ to allow users to sign up using their phone number, you can pass `signUpOnVerifi
|
||||
export const auth = betterAuth({
|
||||
plugins: [
|
||||
phoneNumber({
|
||||
otp: {
|
||||
sendOTP: (phoneNumber, code) => {
|
||||
// Implement sending OTP code via SMS
|
||||
}
|
||||
},
|
||||
signUpOnVerification: {
|
||||
getTempEmail: (phoneNumber) => {
|
||||
|
||||
Reference in New Issue
Block a user