Customizable login by different field

Hi guys, 

I need to make a customized login, not by username, but by an extended field instead. 

I Read docs for "add logic", (https://success.outsystems.com/Documentation/Development_FAQs/How_to_add_additional_logic_to_users_login) but in the documentation, this "custom field check" comes after check for username, not before.

What I want to do is make users log in by their CPF (is a unique number of a official ID here in Brazil) not by username.

The "workaround" i'm thinking of is:

1. at login form, use CPF instead of username + password.

2. check into ExtendedUser Entity if this CPF exists. If so, assign the related username value (from USER table) to a variable and then go back to normal login flow as if user had input username value by its own.

Is it possible? How can I do this?

Tks in advance.

Hello.
Your situation in not that uncommon.

The way I see it, there are two easy ways of achieving your goal.


1. The CPF is the username. Nothing says you can't use a number as a username. It is long and unique.

2. You get the CPF, look for it in the Extended table, return the related UserId and then do the Login with UserId and Password. And yes, you can still do all the custom checks after this.


Rodrigo Tafner wrote:

Hi guys, 

I need to make a customized login, not by username, but by an extended field instead. 

I Read docs for "add logic", (https://success.outsystems.com/Documentation/Development_FAQs/How_to_add_additional_logic_to_users_login) but in the documentation, this "custom field check" comes after check for username, not before.

What I want to do is make users log in by their CPF (is a unique number of a official ID here in Brazil) not by username.

The "workaround" i'm thinking of is:

1. at login form, use CPF instead of username + password.

2. check into ExtendedUser Entity if this CPF exists. If so, assign the related username value (from USER table) to a variable and then go back to normal login flow as if user had input username value by its own.

Is it possible? How can I do this?

Tks in advance.

hi, yes you can do it, check the pics, you change the username local variable and input parameter to CPF,

after in the logic you add your aggregate with the user and userExtension filter by the CPF, limit the result to 1, and in the user login get the username from the current line


Ok, got it! Tks

Now, I have another issue regarding this:

As I have an extended entity for User, how can I update (or even better, create) a new row on extended entity?

I created a form with input fields for both entities (as latter is an extension for the former) and by clicking the "save" button, I call a logic flow to "CreateOrUpdate" the database.

The problem is that it only creates a row on the main entity. If I try to do another "CreateOrUpdate" pointing to the second entity I get an exception on User Table form INSERT by restrictions of the FOREIGN KEY.

How should I proceed?


Solution

The Create is only for one entity at a time. After you CreateUser, you can get the User Id (in CreateUser.Id).

Assign the value to UserExtended.Id and then save UserExtended.

Solution

Nuno Reis wrote:

The Create is only for one entity at a time. After you CreateUser, you can get the User Id (in CreateUser.Id).

Assign the value to UserExtended.Id and then save UserExtended.

Just follow what Nuno said, it's exactly that :)


I don't understand... User_Extended.Id is not a variable, right? 

When I try to assign it I get an error: "Can't identify 'User_Extended' element in expression."

What is that I'm not getting?

Tks in advance for your time

You have an Entity UserExtended where attribute Id is of type User Identifier.


I called User_Extended to a variable of type UserExtended.

Think of it as a blank row of that type. You must give it Id=CreateUser.Id so it will have the Id of the User it is associated with. You should also fill some more fields like the CPF or it will be useless.

After you filled it, you save it.

Now I got it!

You created a list!

Worked just fine!

Nuno, como vi que és Português: Muito obrigado, meu caro. Esta eu cá a apanhar...lol!