Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Custom Login Messages

First, I am very new to web application development so this might be a basic question...

With CodeOnTime, I have created a dedicated login page using Active Directory authentication. I have also overridden the UserLogin function in the ApplicationServices class so I can implement my own custom logic. After calling MyBase.UserLogin(...), which will authenticate against the AD, I have my own logic. This works great as I simply have to determine to return True or False appropriately.

My question is how can I provide my own message from my UserLogin() function back to the custom login page? Based upon the valid AD user, I then query our data for some additional information that might prevent them from being able to sign in. How do I notify the user with an appropriate message?

Thank you for the help in advance!
Dave
1 person has
this question
+1
Reply
  • The standard API does not allow returning a custom message.

    The best approach is to create a custom data controller implementing a business rule that will process a login request.

    The server side implementation of the rule will accept UserName and Password fields, will validate them and return a value for the Message field.

    There must be a view in the data controller that will include UserName, Password, and Message fields. The view has to be marked for public access.

    Re-generate your app with a "dedicated login" option configured in Membership settings of the project.

    Change the standard login to use $app.execute client API to invoke the data controller. Analyze the message returned by the method and either reload the page or display the error to the user.

    The server-side "code" business rule must set Message in result to a string that signifies a successful login or to a text message that must be displayed when login has failed. If the user login was successful then make sure to call FomsAuthentication.SetAuthCookie

    The call from the client may be similar to this:


    $app.execute(
    controller: 'MyAuthenticationManager',
    view: 'login',
    command: 'CustomLogin',
    values: [
    {field: 'UserName', value: 'admin' },
    {field: 'Password', value: 'admin123%' }
    ],
    success: function(result) {
    if (result.MyAuthenticationManager.Message == 'ok')
    window.location.reload(__baseUrl);
    else
    $app.alert(result.MyAuthenticationManager.Message);
    }
    );
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Is this recommendation still the best approach to return custom messages about login failure?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated