Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

2. Using Javascript connector

Xelit3 edited this page Nov 6, 2020 · 2 revisions

Frontend tool

ChustaSoft Authorization provides a npm package (@chustasoft/cs-authorization-connector) that allow a frontend to connect with the exposed Controller actions of the AspNet package.

This package is developed purely in TypeScript, so the package can easily integrated in any kind of JavaScript project.

The package provides:

  • AuthorizationService: Connection service with the WebApi
    • async register(credentials: Credentials): Promise
    • async login(credentials: Credentials): Promise
    • async confirm(userValidation: UserValidation): Promise
    • async activate(userActivation: UserActivation): Promise

Example on Angular application

  1. Install @chustasoft/cs-authorization-connector package

  2. Recommended usage of Service with Angular injection:

import { Injectable, Inject } from '@angular/core';
import { AuthorizationService } from '@chustasoft/cs-authorization-connector';

@Injectable({
  providedIn: 'root'
})
export class AuthService extends AuthorizationService {

  //Could it be environment file inestad
  constructor(@Inject('BASE_URL') baseUrl: string)
  {    
    super(baseUrl);
  }

}

With this approach, we will be both injecting the necessary configuration of the base URL of the API to the connector service, and adding the service to the Angular DI Container, therefore available for any component.

You will be able to found a complete example with Backend + Frontend, using Nuget packages and npm connector here

Clone this wiki locally