Oouhammmourachid /
Public
ouhammmourachid / auth-profiles
PublicEvery signup gets a public profile with a unique username, avatar and bio. Works with email/password and OAuth2 signups.
- Auth
- 0 deploys
- 0 forks
Auth + Public Profiles
Every signup gets a public profile with a unique username, avatar and bio. Works with email/password and OAuth2 signups.
What you get
- A profile is created automatically for every new user, including OAuth2 signups
- Usernames are unique, lowercase, and generated from the user's name or email
- Reserved usernames (admin, api, support...) are refused
- Profiles are public to read; only the owner can edit theirs
- Avatars with 100x100 and 400x400 thumbnails
- Leaves the built-in
userscollection untouched, so private fields like email stay private
Collections
profiles
Created by a hook when a user signs up; deleted with the user.
| Field | Type | Notes |
|---|---|---|
user (required) | relation → users | One profile per user |
username (required) | text | Unique, a-z 0-9 _ |
display_name | text | |
avatar | file | Images up to 5 MB |
bio | text | |
website | url | |
location | text |
| Action | Who can do it |
|---|---|
| List / view | anyone |
| Create | superusers only |
| Update | user = @request.auth.id |
| Delete | superusers only |
Hooks
All hooks are in pb_hooks/main.pb.js and commented.
Setup
- Turn on the OAuth2 providers you want under users > Options > OAuth2.
Quick start
import PocketBase from "pocketbase"
const pb = new PocketBase("https://YOUR-INSTANCE.pocketshub.com")
await pb.collection("users").create({ email, password, passwordConfirm: password, name: "Sam Lee" })
await pb.collection("users").authWithPassword(email, password)
const me = await pb.collection("profiles").getFirstListItem(`user = "${pb.authStore.record.id}"`)
await pb.collection("profiles").update(me.id, { username: "samlee", bio: "Building things." })
// Public profile page:
const profile = await pb.collection("profiles").getFirstListItem(`username = "samlee"`)
License
MIT
1 collection, 0 relations