General
Turn login on, choose when customers must sign in, and tell Twinr how to recognise a signed-in customer.
Your app signs customers in using your website's own login page. Twinr does not replace it or store any credentials — it opens your sign-in form inside the app and watches the page to work out whether the customer is signed in.
That is why this screen needs a short script from you. Your site already knows who is signed in; this tells Twinr how to read that.
The three toggles

Enable login process
The master switch. With it off, nothing else on this screen applies and your app has no sign-in step.
Require login at the start
On: customers see the sign-in screen before anything else. Off: they can browse, and are asked to sign in only when they reach something that needs it.
Keep users logged in
On: customers stay signed in between visits. Off: they sign in each time they open the app.
Keep users logged in should almost always be on. Signing in on a phone is tedious, and an app that forgets you every time feels broken.
Login status check script
This is the part that does the real work. Twinr runs your script against the page and expects it to return one of four statuses:
loggedIn
The customer is signed in. Twinr lets them through.
notLoggedIn
They are not signed in.
authError
They tried to sign in and the details were wrong.
unknown
Nothing matched. Use this as your fallback.
The names must match exactly.
How to write it
Each status is a selector that only exists on a page in that state. Open your site in a desktop browser and use the inspector to find one:
notLoggedIn— something unique to your sign-in page, usually the form itself.loggedIn— something that only appears once signed in, such as a sign-out link or an account menu.authError— the error message shown after a failed attempt.
Here is a real example:
Check the error case carefully. Sites often use different messages for a wrong password, an unknown email, and a locked account. Cover them all with ||, or a customer who mistypes their password sees nothing happen:
Test it before you save
Open your site in a desktop browser, paste the script into the developer console, and check it returns the right status. Then sign in and run it again — it should change to loggedIn. Finally, try a wrong password and confirm you get authError.
If it returns the right value in all three states, it will work in the app.
Login page selectors
Twinr needs to find the parts of your sign-in form so the app can work with it.

Login form selector
The <form> element that holds your sign-in fields.
Submit button selector
The button that submits it.
Username field selector
The email or username input.
Password field selector
The password input.
Prefer an id such as #email over a class — class names change when your theme is updated, and a changed class quietly breaks sign-in for everyone.
Click Save as draft when you are done.
Common Questions
Last updated