53
Views
13
Comments
Login using own entity
Question
Application Type
Reactive
Service Studio Version
11.54.65 (Build 63363)
Platform Version
11.29.0 (Build 43552)

hi i am trying to create a login function without using the user entity and using my own entity and putting encrpytion for authenticiy. how can i achieve possible achieve this? thanks!! been finding many forums but there is no answer to this, thank you for helping me 

loginstests.oml
2024-05-30 10-12-48
Anushka singh

Hello

this oml use customlogin

i hope it helps!

loginstests.oml
UserImage.jpg
budang haba

thank you opr replying!! but it doesntw ork :((

2024-05-30 10-12-48
Anushka singh
UserImage.jpg
budang haba

in my login screen i want to use my own entity  to login that i made instead of the user outsystem entity. how can i achieve this ? 

2024-05-30 10-12-48
Anushka singh

You can check osm carefully I am also using own entity do not using outsystems entity and login.i am using custom login ans entity 

UserImage.jpg
budang haba
2024-05-30 10-12-48
Anushka singh

ok you can check update oml i hope it helps!

loginstests.oml
UserImage.jpg
budang haba

you really are life saver sir! thank you soomucha, and last one question may i know if i want my password is date type? i have this problem wherein i have this problem in my generatesaltedmd5hash password is there a way i can put it in date type? thanks sir

2024-06-23 12-44-04
Adnan Aboobaker

Hi @budang haba ,

In OutSystems, the built-in user authentication and session management are tightly coupled with the Users module and its associated entities. While it's not recommended to completely bypass this system, you can create a custom authentication solution that works alongside the built-in one. Here's a more detailed approach:

  1. Custom Entity Approach: Create your own custom entity (e.g., 'Employee') with the necessary fields for authentication, including a unique identifier that can be linked to the Users entity.
  2. Custom Authentication Logic: Implement your own authentication logic using your custom entity. This is where you can apply your desired encryption and authenticity checks.
  3. Link to Users Entity: After successful authentication with your custom entity, you'll need to link it to the Users entity to properly create an OutSystems session.
  4. Use System Actions: Instead of using the 'User_Login' action from the Users module, you can use the more low-level 'Login' action from the System module. This allows you to create a session without directly interacting with the Users entity.

Here's a step-by-step process:

  1. Authenticate using your custom entity (e.g., 'Employee').
  2. If authentication is successful, retrieve or create a corresponding UserId in the Users table.
  3. Call the System.Login action with the UserId. This creates the necessary session.

Example pseudo-code:

// Your custom authentication logic

If AuthenticateEmployee(username, password) Then

    // Get or create a corresponding User

    userId = GetUserId(employeeId)

    // Create OutSystems session

    System.Login(userId)

    // Additional custom logic as needed

End If

This approach allows you to use your custom entity and encryption methods while still leveraging OutSystems' session management capabilities. Remember to handle user roles, permissions, and other session-related information that might typically be managed by the Users module.

Keep in mind that while this method works, it bypasses some of OutSystems' built-in security features. Ensure you implement proper security measures in your custom authentication logic.

For encryption, you can use OutSystems' built-in cryptographic functions or integrate with external encryption libraries if needed.

If you need more specific guidance on implementing encryption or any part of this process, feel free to ask!

UserImage.jpg
budang haba

THANKS FOR This explanation and tips sir but im not that good at following in terms of reading im more of a visual and hoping you have an oml example for this but thanks sir!!!

UserImage.jpg
Shailesh Keshri

// CustomUser Entity

// Attributes: Id (Identifier), Email (Text), Password (Text)


// RegisterUser Action

Input: Email (Text), Password (Text)

Output: OutputMessage (Text)


HashedPassword = CryptoAPI.HashPassword(Password)


UserRecord.Email = Email

UserRecord.Password = HashedPassword

CreateCustomUser(UserRecord)


OutputMessage = "User registered successfully"


// LoginUser Action

Input: Email (Text), Password (Text)

Output: OutputMessage (Text)


UserRecord = GetCustomUserByEmail(Email)


If (UserRecord != Null) {

    IsPasswordValid = CryptoAPI.VerifyHashedPassword(UserRecord.Password, Password)


    If (IsPasswordValid) {

        OutputMessage = "Login successful"

    } else {

        OutputMessage = "Invalid credentials"

    }

} else {

    Outp

utMessage = "User not found"

}

UserImage.jpg
budang haba

what you mean by this sir

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.