Custom-security-rules

Looking to use both the registration and email validation together.
Looking at Securing your apps | Fliplet Developers Documentation

The sample code looks as if it will adapt however it is 20 years since I coded would the changes work, plus I want to include Onboarding, Login, Registration, Email Validation - can you clarify what the other screen names would be?

var loginScreen = 123;
var hasSession = session && session.entries && session.entries.dataSource;
var isAllowed = hasSession && session.entries.dataSource.data[‘verifiedAt’] == null;

if (server && page.id !== loginScreen && !isAllowed) {
error = true;
navigate = { action: ‘screen’, page: loginScreen, transition: ‘slide.left’ };
}

Hi mark,

You will need something like this:

Please put the page Id’s of all the pages you want excluded at the top. If a user is not logged and they try to access any other page then they will be take to the loginPage below.

var onboardingPage = 123456;
var loginPage = 123456;
var registrationPage = 123456;
var emailValidation = 123456;

var isAllowed =
  (session && session.entries && session.entries.dataSource) ||
  (page.id === onboardingPage ||
    page.id === loginPage || 
    page.id === registrationPage ||
    page.id === emailValidation);

if (server && page.id !== loginPage && !isAllowed) {
  error = true;
  navigate = { action: 'screen', page: loginPage, transition: 'slide.left' };
}

Hi Deb

Just to clarify what we need to do.

You have two components, Registration and email validation. Currently they do not work together.

Email validation puts a datetime stamp in the user table in ‘ verifiedAt’.

Hence the query about the custom code – so it checks both registration and that verifiedAt has something in it.

Going to the page below it give the code sample. Which suggests session.entries.dataSource.data[‘foo’] !== ‘bar’; - modified would check the email validation.

https://developers.fliplet.com/App-security.html

Hi
I should have also said that in the code you show I can’t see how it also checks the email validation. But I haven’t coded for a very long time so may be mistaken.

Hi Mark,

Thank you for the clarification. In this case I suggest the following. This will check if your verifiedAt is not null and if it is then it will take you to the login page.

var loginPage = 123456;
var registrationPage = 123456;
var emailValidation = 123456;

var isAllowed =
  (session && session.entries && session.entries.dataSource) || hasSession && session.entries.dataSource.data[‘verifiedAt’] != null ||
  (page.id === onboardingPage ||
    page.id === loginPage || 
    page.id === registrationPage ||
    page.id === emailValidation);

if (server && page.id !== loginPage && !isAllowed) {
  error = true;
  navigate = { action: 'screen', page: loginPage, transition: 'slide.left' };
}