Skip to content

Commit

Permalink
docs: wrong phone number api
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekacru committed Oct 17, 2024
1 parent 8bc293a commit cda582f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
30 changes: 30 additions & 0 deletions demo/nextjs/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
6 changes: 2 additions & 4 deletions docs/content/docs/plugins/phone-number.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
sendOTP: (phoneNumber, code) => {
// Implement sending OTP code via SMS
},
signUpOnVerification: {
getTempEmail: (phoneNumber) => {
Expand Down

0 comments on commit cda582f

Please sign in to comment.