Skip to main content
Technical Enough

Add accounts and member-only pages

Chapter 5 of 7 in Build Your Website or Mobile App · 21 min

The club decides that the details of each week's run, the meeting point, the time, and the route, should be for members only. You ask the agent to add a sign-in box and a new Members page, and to show the link to that page only to people who have signed in. It works when you try it. A few days later a member pastes the address of the Members page into the club's public group chat, and a friend of theirs who has never signed in opens it and sees everything. The site had hidden the link, but the page itself never checked who was asking for it.

An account is a record your site keeps for one person, so that the site can tell who is using it and show that person their own information. In Auth, who you are vs. what you can do you learned the two checks behind every account, who you are and what you may do, and you wrote them down as a three-line spec. In this chapter you build both checks into the running-club site: members sign in, the site stores each member's information separately, and the member-only pages open only for members who are signed in.

Decide who signs up, how they sign in, and what a member can do

Start with the three lines of the auth spec, because the agent builds from them. For the running club they are:

AUTH SPEC
Who signs up:   anyone with an email address
How they sign in:  a link sent by email, or Google
What each one may do:
  visitors   see Home, Trails, and Join
  members    see the week's run and RSVP, and see
             and change only their own details
  organizer  also edits the week's run

The second line needs a choice. Members can sign in in three common ways:

  • A link sent by email. The member types their email address, the site emails them a link, and clicking the link signs them in. This is a sign-in link. The member has no password to remember, and there is no password for anyone to steal. In the service this course uses, a link works once and stops working after an hour unless you change that setting.
  • An account they already have. A "Sign in with Google" button lets the member use their Google account, and Google confirms who they are. It needs some extra setup on Google's side, and the agent can take you through it.
  • A password. This is the most familiar way and the weakest one, because people use the same password on many sites. Offer it only if your members ask for it.

The running club starts with the sign-in link and adds Google.

Use a sign-in service so your site never stores a password

A sign-in service is a company that runs sign-in for your site. It sends the sign-in emails, confirms who each person is, and keeps any passwords on its own computers, so your site never stores one. This course uses Supabase, which also provides the database you need later in this chapter, so one account with it covers both.

The agent does most of the typing. These are the steps you follow along with:

  1. Create a project at the sign-in service. The service gives your project two keys.
  2. Put each key in the right place. One key is public (Supabase calls it the publishable key), and it goes in the pages of your site, where any visitor can see it. The other is the secret key. It can read and change everything in your database, so it goes only in the .env file on your laptop and on the Environment Variables screen at your host, the two places you used in Environments: why it works on your machine and breaks online.
  3. Turn on the ways to sign in. In the service's settings, choose the sign-in link and Google.
  4. Connect your email service. Until you do, the sign-in service only sends email to you and the other people working on your project. Connect the email service from Set up your own domain name and email, and the sign-in emails come from hello@runclub.example and reach every member.
  5. Tell the service the address of your site. After a member clicks the link, the service sends them back to your site, and it only sends people to addresses you have listed. Add your domain name, and add localhost, the address the site uses on your laptop, so that you can test.

Move the club's data into a database, with a rule on every table

Until now the trails and RSVPs have been stored in one file, data/club.json. A file cannot give one member their own part of it, because anyone who can open the file can open all of it. Accounts need a database, which Data, where information lives described: the information is stored in tables, with one row for each record. Ask the agent to move the club's data into tables like these:

members
id | email            | name
1  | [email protected] | Asha
2  | [email protected]  | Leo

rsvps
id | member_id | run           | coming
1  | 1         | weekend run   | yes
2  | 2         | weekend run   | no
3  | 1         | track session | yes

Every row in the rsvps table has a member_id, the id of the member it belongs to. That column is what lets the database keep one member's rows apart from another's.

Storing the id is not enough, because the database also has to check it. Row Level Security is a rule you set on a database table. The database checks the rule on every request, before it returns or changes any row. The rule for the rsvps table says that a member can read and change only the rows with their own member_id.

You need this rule on every table for a specific reason. The public key from step 2 is in every visitor's browser, and with it a browser can ask the database for rows directly. If a table has no rule, the database answers anyone who has that key, and everyone has it. If the table has a rule, the database returns only the rows the rule allows. So turn the rule on for every table, including the ones that seem harmless, and ask the agent to list each table with its rule.

Every row in the database records which member it belongs to, and the database checks that on every request. A member who asks for another member's row gets nothing back, whichever page or address they use.

Check who is asking before a member-only page is sent

The Members page in the opening scene had no check of its own. Hiding a link changes what a visitor sees on the screen. It does not stop anyone from opening the page if they have its address.

A member-only page is safe when the server does the checking. Before the server sends the page, it asks the sign-in service whether this visitor is signed in. If they are, the server sends the page. If they are not, it sends them to the sign-in page instead. The server has to confirm the sign-in with the sign-in service every time. It cannot simply accept what the browser tells it, because a person can make a browser send whatever they like.

Give the agent that instruction in these words: "Before any member-only page is sent, check on the server that the visitor is signed in, and confirm it with the sign-in service. Do not rely on hiding links."

After a member signs in, the site remembers them with a session, the signed-in state from the auth chapter, so they do not need a new link every time they visit.

A member-only page is protected only when the server checks who is asking before it sends the page. Hiding the link to a page does not protect the page.

Test with two accounts before any real member signs in

You can check all of this yourself in a few minutes, using two email addresses of your own.

  1. Sign up twice. Create one account with each address, and call them member A and member B.
  2. Open a member-only page while signed out. Copy the address of the Members page. Open a private browser window, where you are not signed in, and paste the address. You should arrive at the sign-in page.
  3. Look for member A's information as member B. RSVP for a run as member A. Then sign in as member B and look for that RSVP wherever a member's own details appear. If the address of a page contains a number or a name, change it to member A's, which is the test from the auth chapter. You should find nothing of member A's.
  4. Check the tables. Open the database's dashboard, look at each table, and confirm that each one has a rule.

If a test fails, tell the agent which test it was and what you saw, and run all four again after the fix.

The obvious objection: the agent set up sign-in from one request, so it is already safe

The agent can add a working sign-in from one sentence, and that sign-in does work. But a working sign-in only confirms who each person is. Which rows a member can read, and which pages open for whom, are rules that you have to state, because the agent cannot guess them. You also have to test them, because a site with a missing rule works normally for everyone who uses it as intended, and you only find the gap by trying what a stranger would try.

What happened to a site whose database had no rules

In January 2026 a social network called Moltbook became popular very quickly. Its founder said publicly that he had not written a single line of its code and that an AI tool had built it. On January 31, researchers at the security company Wiz looked at the site the way any visitor could. They found the public key for its database in the page, which is normal for the database service it used, the same one this course uses. The rules that limit what that key can reach had not been turned on. Using only that key, the researchers could read and change every table. The tables held 1.5 million secret tokens that let programs act as accounts, 35,000 email addresses, and private messages. The researchers told the founder, and all the tables were secured about three hours later.

What you can do now

You can choose how members sign in, set up a sign-in service so that your site never stores a password, store each member's information in a database with a rule on every table, and make member-only pages check on the server who is asking. You can also test all of it yourself with two accounts, without reading any code.

Try it now

This drill takes about twenty minutes, and you spend nothing on either path. The sign-in service has a free plan, and it is enough for the drill.

No setup: Choose a site where you have an account and can see something private, such as your past orders at an online shop. Sign in, open the page that lists your orders, and copy its address. Open a private browser window, where you are not signed in, and paste the address. A site that checks on the server sends you to its sign-in page. Then go back to the sign-in screen and write down which ways to sign in it offers: a link sent by email, a password, or an account you already have, such as Google or Apple.

With your tools: Open Claude Code in the running-club folder, or in your own project, and type: "Add accounts with Supabase. Members sign in with a link sent by email. Move the data in data/club.json into database tables, and turn on Row Level Security on every table so that a member can read and change only their own rows. Make every member-only page check on the server that the visitor is signed in. When you are done, list every table and the rule on it." Follow the five steps in this chapter as the agent reaches them, then run the two-account test. Codex and Cursor accept the same request in their chat panels. If nothing is installed yet, The Setup Clinic covers the install.

Either way, finish by adding these lines to the idea file. If you took the first path, write them for the site you tested.

Accounts: anyone can sign up; sign-in by email link
          and Google, through a sign-in service
Members:  see the week's run and RSVP; each member
          sees only their own details
Checked:  signed out, and as a second member
Keys:     secret key in .env and on the host only

Chapter Summary

  • An account is a record your site keeps for one person, so the site can tell who is using it and show that person their own information.
  • Before the agent builds anything, write the three lines of the auth spec: who signs up, how they sign in, and what each kind of user may do.
  • With a sign-in link sent by email, members have no password to remember or lose. A "Sign in with Google" button lets them use an account they already have.
  • A sign-in service runs sign-in for you, so your site never stores a password. Its public key goes in your pages, and its secret key goes only in the .env file and on the host.
  • Connect your email service to the sign-in service, so that sign-in emails come from your own domain name and reach every member.
  • Move the club's data from a file into database tables in which every row records the member it belongs to.
  • Turn on Row Level Security for every table. It is a rule the database checks on every request, so a member gets back only their own rows.
  • A member-only page is protected only when the server checks who is asking before it sends the page. Hiding the link does not protect it.
  • Test with two accounts of your own: open a member-only page while signed out, and look for one member's information while signed in as the other.
  • Your artifact is the idea file, which now has four lines about accounts: who can sign up and how they sign in, what members see, how you checked it, and where the keys are kept.
  • The next chapter is Take payments for memberships and a shop, where members pay for their membership on the site.

Sources

  • Supabase documentation on Row Level Security, on API keys, on server-side sign-in for Next.js, on signing in with a link sent by email, on signing in with Google, and on sending sign-in emails through your own email service (last verified November 2026).
  • Supabase pricing page, for the free plan (last verified November 2026).
  • Wiz Research, "Hacking Moltbook: The AI Social Network Any Human Can Control", published February 2, 2026 (last verified November 2026).