Class AuthService

Class containing authorization related methods.

Hierarchy

Constructors

Properties

constructor: typeof HttpService
http: any

Methods

  • Allow applications to access displayed user information. When third-party applications request to access user information they need the consent of the end user. This method will allow the 3rd party application to receive the information. Allow button in Consent view uses this method.

    Example

    auth.acceptConsent()
    

    Returns Promise<any>

  • Helper method for checking password strength for rules defined in PlusAuth. This method would be useful in SignUp and ResetPassword views.

    Example

    const password = '123'
    const passwordRules = window.PlusAuth.passwordPolicy

    const passwordStrength = auth.checkPasswordStrength(password, passwordRules)

    if( passwordStrength === true ){
    console.log('password is strong enough')
    } else {
    console.log('Password is not strong enough', passwordStrength)
    }

    Parameters

    • value: string

      Password to check

    • passwordRules: any = {}

      Object containing password rules

    Returns any

  • Forbid applications to access displayed user information. When third-party applications request to access user information they need the consent of the end user. This method will reject the 3rd party application's request to receive the information. Reject button in Consent view uses this method.

    Example

    auth.rejectConsent()
    

    Returns Promise<any>

  • Request password reset email. Forgot Password view in PlusAuth uses this method to post the form.

    Example

    auth.requestResetPassword('john@doe.com')
    

    Parameters

    • email: string

      Email of user requesting password reset.

    Returns Promise<any>

  • After clicking the reset password email, users will be delivered on a page which will request their new password. Use this method to post their new password and token from the url. If Auto SignIn is enabled in Settings > Login user will be redirected to Tenant Login URL automatically. Reset Password view in PlusAuth uses this method to submit the form.

    Example

    const pathParts = location.pathname.split('/')
    const token = pathParts[pathParts.length - 1];

    auth.resetPassword('NEW_PASSWORD', token).then(function(){
    console.log('Password reset successfully')
    })

    Parameters

    • password: string

      New password of user

    • hash: string

      Received token in the url

    Returns Promise<any>

  • Submits user credentials to the endpoint /signin.

    Example

    Here is a simple usage.

     auth.signIn( { username: "johndoe@example.com", password: "mypassword" } )
    

    Example

    With different strategy.

     auth.signIn( { username: "johndoe@example.com", password: "mypassword" }, "myLdapStrategy" )
    

    Parameters

    • fields: {
          [key: string]: any;
      }

      Key/Value object for validating user.

      • [key: string]: any
    • Optional strategy: string

      PlusAuth strategy to check user. Make sure you have created this strategy in your tenant.

    Returns Promise<any>

  • Posts a request for registering a user.

    Example

    Here is a simple usage.

     auth.signUp( { username: "johndoe@example.com", password: "mypassword" } )
    

    Example

    With phone number.

     auth.signUp( { username: "johndoe@example.com", password: "mypassword", phone_number: '+11231212123' } )
    

    Example

    With different strategy.

     auth.signUp( { username: "johndoe@example.com", password: "mypassword" }, "myLdapStrategy" )
    

    Parameters

    • fields: {
          [key: string]: any;
      }

      Key/Value object containing user information.

      • [key: string]: any
    • Optional strategy: string

      PlusAuth strategy to create the user for. Make sure you have created this strategy in your tenant.

    Returns Promise<any>

  • In some cases user may need to enter additional information for their profile. For example applications may force users to enter their phone number. Fill Missing view in PlusAuth uses this method to post the form.

    Example

    auth.updateMissingInformation({ phone_number: '+1222334455'})
    

    Parameters

    • fields: {
          [key: string]: any;
      }

      Key/Value object containing user information

      • [key: string]: any

    Returns Promise<any>

Generated using TypeDoc