-1

I want to separate the login/register workflow into an isolated module. So far I created the module (ng g module login-module) and I want to add the Facebook and Google SDKs to it.

The thing is, the main module (AppModule) is the responsible for the dependencies (package.json) and I would like to isolate the dependencies for the login/register workflow too.

That means that my LoginModule should be an Angular App by itself (created with ng new login-module)?

Jota.Toledo
  • 22,272
  • 8
  • 48
  • 63
forkfork
  • 365
  • 4
  • 17

2 Answers2

0

No, modules are a way of puting together elements, "functional units", that relate to each other. They are by no means an individual application, although good encapsulation could allow you to transform a module into an independent application. You could read a lot more about it here

Jota.Toledo
  • 22,272
  • 8
  • 48
  • 63
0

In a normal situation you don't want to have to applications (i.e. 2 websites) where one is responsible for stuff and the other for authentication. Stuff would still need to make requests to the authentication and then .. why separate that?

Also there are different things you talk about. You want to separate the flow and you look into the right direction with module.

But then, other parts of your application might need to check whether somebody is authenticated and display a message or not allow certain things.

So go ahead and create the module which handles the interaction with the user (registration form, login form). Thats the right thing.

Then use a auth-service to handle and store the current state. And beside storing tokens this should also orchestrate which method to call (Google login or FB login)

Set up a structure recommended by John Papa here: https://angular.io/docs/ts/latest/guide/style-guide.html under the section Application structure and Angular modules

Use package.json and import at the places (the auth-service).. Export the auth-service to a core-module and import this core-module into the app-module and the application modules where you need the functionalities of that one core-module.

hogan
  • 1,145
  • 12
  • 26