mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 12:27:44 +00:00
docs: wrong phone number api
This commit is contained in:
@@ -89,6 +89,36 @@ export const auth = betterAuth({
|
|||||||
passkey(),
|
passkey(),
|
||||||
bearer(),
|
bearer(),
|
||||||
admin(),
|
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: {
|
socialProviders: {
|
||||||
github: {
|
github: {
|
||||||
|
|||||||
@@ -92,10 +92,8 @@ to allow users to sign up using their phone number, you can pass `signUpOnVerifi
|
|||||||
export const auth = betterAuth({
|
export const auth = betterAuth({
|
||||||
plugins: [
|
plugins: [
|
||||||
phoneNumber({
|
phoneNumber({
|
||||||
otp: {
|
sendOTP: (phoneNumber, code) => {
|
||||||
sendOTP: (phoneNumber, code) => {
|
// Implement sending OTP code via SMS
|
||||||
// Implement sending OTP code via SMS
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
signUpOnVerification: {
|
signUpOnVerification: {
|
||||||
getTempEmail: (phoneNumber) => {
|
getTempEmail: (phoneNumber) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user