Signing

Check if a user has Signicat MobileID

300 views August 3, 2017 August 14, 2018 3

Every user needs to have an external_reference, which most likely corresponds to a unique user identifier in your system. The external_reference could be an e-mail address, a user ID, a phone number, a national identity number or anything that is unique for each user in your service and domain.

In the following example, we will assume that the end user inputs his/her e-mail address as the user ID, and this is also the key used as the external_reference. In order to find out if the user is registered or not, you may choose between calling any of the following methods in the IdpService:

  • getDevices – returns a list of all devices associated with the account
  • getAccount – returns information about the associated account

Most likely, you will use the getDevices method since it will provide you with information on all of the registered devices for a user, if successful. Calling any of these methods with an invalid/ unregistered external_reference will throw an exception.

Using C#
public ActionResult Login(string email)
{
    using (var client = new IdpEndPointClient())
    {
        var request = new getdevicesrequest
        {
            service = Properties.Settings.Default.Service,
            password = Properties.Settings.Default.Password,
            domain = Properties.Settings.Default.Domain,
            external_reference = email
        };
        try
        {
            var response = client.getDevices(request);
            if (response.devices.Length == 1)
            {
                return RedirectToAction(
                    "StartAuthentication",
                    new
                    {
                        email = email,
                        deviceName = response.devices[0].name
                    });
            }
            else
            {
                return RedirectToAction("SelectDevice", new { email = email });
            }
        }
        catch (FaultException e)
        {
            return RedirectToAction("Register", new { email = email });
        }
    }
}

Was this helpful?