Skip to content

UserLogin - cWebSessionManagerStandard

Attempts to login in a user with the passed user name and password

Type: Function
Return Data Type: Boolean

Parameters

Parameter Type Description
sLoginName String The login name
sPassword String The password

Syntax

Function UserLogin String sLoginName String sPassword Returns Boolean

Call Example

Get UserLogin sLoginName sPassword to BooleanVariable

Description

This is the function that performs a user login. It passes a user name and password, which it attempts to match against the WebAppUser table. If it succeeds, it will set psUserName, psLoginName and piUserRights and returns True. After a login, you can use these properties to determine behaviors within your application. If it fails, it returns False.

The login dialog calls this function to perform the login. Here is the code in LoginDialog.wo:

Procedure DoLogin
    String sLoginName sPassword
    Boolean bResult
    Handle hoDefaultView

    WebGet psValue of oLoginName to sLoginName
    WebGet psValue of oPassword to sPassword

    Get UserLogin of ghoWebSessionManager sLoginName sPassword to bResult

    If (bResult) Begin
        Send Hide of oLoginDialog
        Get phoDefaultView to hoDefaultView
        If (hoDefaultView > 0) Begin
            Send Show of hoDefaultView
        End

        // clear the login values. we don't want to return the login id & password as web properties....
       WebSet psValue of oLoginName to ""
        WebSet psValue of oPassword  to ""
        WebSet pbVisible of oWarning to False
    End
    Else Begin
        WebSet pbVisible of oWarning to True
    End
End_Procedure

You can call UserLogin to perform a custom login. For example, this code can be added to the top of your WebApp.src where it will perform an automatic login. This can be particularly useful during development allowing you to bypass a manual login, while still being able to test various login rights levels.

Object oWebApp is a cWebApp
    Set psTheme to "Df_Web_Creme"

    // this will do a manual login
    Procedure OnLoad
          Boolean bOk
          Get UserLogin of ghoWebSessionManager "john" "John" to bOk
   End_Procedure
    :

Return Value

Returns True if the login was successful, else returns False