Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Integrate or Inject Authentication authorization module in Modular Approch #68

Open
brijesh1ec opened this issue Jun 10, 2016 · 15 comments

Comments

@brijesh1ec
Copy link

Dear All,

I have been trying to integrate Authentication and Authorization module for feature wise application(modular approach) . steps below tried.

  1. under app-> Login && Logout folder with module , controller,services. which is getting the top most parent module (login & log out) .

  2. how to access the authentication values($cookies.get(AUTH_USER) in nested/ child module.

  3. how to share data in modular approach.

  4. created login page, and startup page(.html) file. i have attached the folder structure how i am implementing,

Please advice and help . Thanks in advance.

modular folder structure
.

@brijesh1ec brijesh1ec changed the title How to Integrate of Inject Authentication authorization module in Modular Approch How to Integrate or Inject Authentication authorization module in Modular Approch Jun 10, 2016
@vazh
Copy link

vazh commented Jun 10, 2016

why do you have so many root html file ?

for role based auth maybe you can check out here:
http://stackoverflow.com/questions/22537311/angular-ui-router-login-authentication

@brijesh1ec
Copy link
Author

Hi,

As in Single Page application there should be only one root file , that
will load all the needed script,css files. and route to login if no matched
route is found.

  1. in blur admin there is Index.html is root page. i want to make this page
    as Master page(welcome page). once user logs in to the application.
    index.html should be opened as welcome page showing some dashboard and
    menus.

  2. i have created login.html page that is loaded when . application is
    requested for first time, and it will load all the script and css file,
    and will show the login page. once user logs in will route to index.html
    page as welcome page(master page).

  3. where i can write/implement authentication logic as app.page is
    parent module for all the pages and routes. should i write authentication
    logic over there.

  4. how i can access the authentication parameters in child or other routes
    if required for authorization.

Please suggest , thanks in advance.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Sat, Jun 11, 2016 at 3:51 AM, VAZH [email protected] wrote:

why do you have so many root html file ?

for role based auth maybe you can check out here:

http://stackoverflow.com/questions/22537311/angular-ui-router-login-authentication


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbGm5JcwV5f9SSzhEPaCb7s_tu3aqks5qKeNPgaJpZM4IzIz1
.

@brijesh1ec
Copy link
Author

Hi VAZH,

as per my requirement i have created root file startup.html, that loads the
login.html once it logs in, shall write authentication on page.module.js
file to authenticate the user and route them accordingly.

  1. how i can access the authentication inside app.page.admin or
    app.page.customer folder, where another child modules are there.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Sat, Jun 11, 2016 at 3:51 AM, VAZH [email protected] wrote:

why do you have so many root html file ?

for role based auth maybe you can check out here:

http://stackoverflow.com/questions/22537311/angular-ui-router-login-authentication


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbGm5JcwV5f9SSzhEPaCb7s_tu3aqks5qKeNPgaJpZM4IzIz1
.

@lugovsky
Copy link
Member

Hi @brijesh1ec

You can create some module, which would not be UI-related. For example, you can name it app.security. This module can contain all code related to authentication and other security stuff, which is not related to actual presentation (HTML, routes, etc.). Then other modules (including module containing UI for authentication) can use that module as a dependency.

Hope this will help you

@vazh
Copy link

vazh commented Jun 13, 2016

@brijesh1ec you can find about auth in this Stackoverflow.

i usually use nested route for such occasion.
say i have 2 level 0 route : login & app
if no auth found redirect to login. else go to app.

so i only use 1 html in the root of the application.

@brijesh1ec
Copy link
Author

Dear All,

  1. I have created one authentication module named it "aurthorization"
    with controller and services communicating to WebApi

  2. in controller based on authentication using $state.go("welcome"). will
    land the user to welcome page(where all menu ,header,footer) which
    index.html page.

  3. using the same module in app.pages (pages.module.js) where all routes
    for nested/child module will be initiated using $stateProvider.

  4. can i use $cookie to communicate between modules (parent-child)? . i
    have created the authentication module and injected to all the module.
    but unable to access cookie

i will share my code under issue. please review and do the needful.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Mon, Jun 13, 2016 at 2:15 AM, Vladimir Lugovsky <[email protected]

wrote:

Hi @brijesh1ec https://github.com/brijesh1ec

You can create some module, which would not be UI-related. For example,
you can name it app.security. This module can contain all code related to
authentication and other security stuff, which is not related to actual
presentation (HTML, routes, etc.). Then other modules (including module
containing UI for authentication) can use that module as a dependency.

Hope this will help you


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbElxvbw-tXAHMMWCxcyZFEIssdVlks5qLG_jgaJpZM4IzIz1
.

@vazh
Copy link

vazh commented Jun 13, 2016

@brijesh1ec use services if you really need to transfer data between controller.
far easier for testing purposes, and also way more clean that way.
but sometimes it depends on what kind of data that you need to pass from/to parent/child

@brijesh1ec
Copy link
Author

as of now i want to transfer the cookies and some parameter values between
modules/controller,

Yes i am using service , injected into controller.

as i am new to angular, how i can using routing for nested module and
sharing cookies between parent module.

Ex. parent module app.pages(page.module.js) i authenticate here and create
cookies, now if i move/route to child module. app.pages.dashboard
(dashboard.module.js) so how i can pass the same data,

i have tried creating controller on child module(for dashboard) injecte
$cookies in controller to get the cookies values over there.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Mon, Jun 13, 2016 at 9:50 PM, VAZH [email protected] wrote:

@brijesh1ec https://github.com/brijesh1ec use services if you really
need to transfer data between controller.
far easier for testing purposes, and also way more clean that way.
but sometimes it depends on what kind of data that you need to pass
from/to parent/child


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbF3rhFJQIvvMxKiTET_aBgfy4faLks5qLYNHgaJpZM4IzIz1
.

@vazh
Copy link

vazh commented Jun 14, 2016

like i said, use factory/services.
put the value inside those factory/services. or you can make a session storage factory/services.
that way, when you logging in, if valid it save values/parameters inside factory/session. and then you can access it from another controller. you just need to inject it.

though i dont know much about $cookies. it should work the same.

@brijesh1ec
Copy link
Author

Hi,

I have attached my approach , here with services (authorization module).
after login user should be landing on index.html page(welcome with menu)
and root file is startup.html will load the login page.

under module app.pages based on role & authentication i want to route it to
different child modules.

Please suggest best better session technique in angular.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Tue, Jun 14, 2016 at 7:27 AM, VAZH [email protected] wrote:

like i said, use factory/services.
put the value inside those factory/services. or you can make a session
storage factory/services.
that way, when you logging in, if valid it save values/parameters inside
factory/session. and then you can access it from another controller. you
just need to inject it.

though i dont know much about $cookies. it should work the same.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbMGFH9CwPwhfE4TGtvBnEDLO04uAks5qLgqWgaJpZM4IzIz1
.

@vazh
Copy link

vazh commented Jun 16, 2016

@brijesh1ec where attach ?

the thing is, with cookie and session.
it was stored within browser. in chrome you can check it using developers tool, and go to resources tab.
check that first to see if your cookies is actually written there

@brijesh1ec
Copy link
Author

Hi,

i am progrssed in authentication part. i am able to put and get the value
of $cookies,

  1. created module(app.pages.authorization). injected into module
    app.pages(pages.module.js).

  2. created landing page(Main.html) which will have menus , Top header(user
    profile), footer, and index.html(root file). after this.(it was there in
    index.html page under body tag).

  3. added ui-view(unnamed) to landing page(main.html). that will load the
    content on click of menus in sidebar.(ladning page does't have any body
    tag) only div, other html controls required.

  4. Index.html having another ui-view(un named). under body tag. which loads
    the login into index.html(root) file.

after login page it goes to Main.html page,

ISSUE--

on click of menu in sidebar it, opens the page with parent(index.html)
file(UI-VIEW), overrides the same page, it should open views with
main.html(in same window).

Possible solution 1) named view should be used,
2) can we change sidebar position out of main section,
3) Parent UI-view scope is overriding the Main.html ui-view.

Please suggest thanks in advance.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Thu, Jun 16, 2016 at 5:37 PM, Muhammad Hariz Faza <
[email protected]> wrote:

@brijesh1ec https://github.com/brijesh1ec where attach ?

the thing is, with cookie and session.
it was stored within browser. in chrome you can check it using developers
tool, and go to resources tab.
check that first to see if your cookies is actually written there


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbPTA-EoQ-MX3f8pJwzR4MKjAfWRgks5qMTyGgaJpZM4IzIz1
.

@brijesh1ec
Copy link
Author

Hi,

i am progrssed in authentication part. i am able to put and get the value
of $cookies,

  1. created module(app.pages.authorization). injected into module
    app.pages(pages.module.js).

  2. created landing page(Main.html) which will have menus , Top header(user
    profile), footer, and index.html(root file). after this.(it was there in
    index.html page under body tag).

  3. added ui-view(unnamed) to landing page(main.html). that will load the
    content on click of menus in sidebar.(ladning page does't have any body
    tag) only div, other html controls required.

  4. Index.html having another ui-view(un named). under body tag. which loads
    the login into index.html(root) file.

after login page it goes to Main.html page,

ISSUE--

on click of menu in sidebar it, opens the page with parent(index.html)
file(UI-VIEW), overrides the same page, it should open views with
main.html(in same window).

Possible solution 1) named view should be used,
2) can we change sidebar position out of main section,
3) Parent UI-view scope is overriding the Main.html ui-view.

Please suggest thanks in advance.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Tue, Jun 14, 2016 at 7:27 AM, VAZH [email protected] wrote:

like i said, use factory/services.
put the value inside those factory/services. or you can make a session
storage factory/services.
that way, when you logging in, if valid it save values/parameters inside
factory/session. and then you can access it from another controller. you
just need to inject it.

though i dont know much about $cookies. it should work the same.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbMGFH9CwPwhfE4TGtvBnEDLO04uAks5qLgqWgaJpZM4IzIz1
.

@brijesh1ec
Copy link
Author

Hi ,
I AM NEW to angularJS.

MIssing thing is, how to load the login page.

  1. Create the new module. app.page.login, file Login.module.js file,
  2. create controller Login.controller.js file.
  3. create services Login.Services.js file.
  4. inculde this file in Index.html page.
    it loads the Login page in UI-View under the content page,

ISSUE- Side bar and top navigation appreas, ideally login page should
render fully across the page.

Solution.

  1. Create another root page or main page.

  2. if Index.html is root page then main section should be moved to
    main.html file

  3. Create folder Main , create app.page.main mdoule in Main.module.js file,
    same way add controller and services file.

  4. Inject the app.page.Main module in app.page module and

  5. Include this new .js files in Index.html files.

  6. include UI-VIEW in index.html file,(if it is not there un named
    ui-view). it will load the login page as full page.

  7. on click of login Page user State.go('Main) state to go to main.html
    file which is having main section with Side,Page top, top content and
    another UI-VIEW. which will load the Side bar, page top, and content page,
    on click of menu, it should open the views in content page.

ISSUE- it opens the views with parent UI-VIEW(index.html) not in child
view(Main.html).

There are two UI-Views (un named). one in Index.html page, another in
Main.html page.
how to load the views on click of side bar in content page(main.html). Why
it opens the views with Index.html page. Its really may be a bug or there
way to load the content inside child view(main.html).

total there are 3 UI-VIEW, a) Index.html for login page to render, b)
main.html to render the content,c) which loads submenu iteams( abstract
true).

In Blur admin there are two UI-VIEW which works fine, why it doesn't works
with 3 UI-VIEW.

Please Suggest me on this. how it can be fixed.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Thu, Jun 16, 2016 at 10:45 PM, Brijesh Pal [email protected] wrote:

Hi,

i am progrssed in authentication part. i am able to put and get the value
of $cookies,

  1. created module(app.pages.authorization). injected into module
    app.pages(pages.module.js).

  2. created landing page(Main.html) which will have menus , Top header(user
    profile), footer, and index.html(root file). after this.(it was there in
    index.html page under body tag).

  3. added ui-view(unnamed) to landing page(main.html). that will load the
    content on click of menus in sidebar.(ladning page does't have any body
    tag) only div, other html controls required.

  4. Index.html having another ui-view(un named). under body tag. which
    loads the login into index.html(root) file.

after login page it goes to Main.html page,

ISSUE--

on click of menu in sidebar it, opens the page with parent(index.html)
file(UI-VIEW), overrides the same page, it should open views with
main.html(in same window).

Possible solution 1) named view should be used,
2) can we change sidebar position out of main section,
3) Parent UI-view scope is overriding the Main.html ui-view.

Please suggest thanks in advance.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Tue, Jun 14, 2016 at 7:27 AM, VAZH [email protected] wrote:

like i said, use factory/services.
put the value inside those factory/services. or you can make a session
storage factory/services.
that way, when you logging in, if valid it save values/parameters inside
factory/session. and then you can access it from another controller. you
just need to inject it.

though i dont know much about $cookies. it should work the same.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbMGFH9CwPwhfE4TGtvBnEDLO04uAks5qLgqWgaJpZM4IzIz1
.

@brijesh1ec
Copy link
Author

Hi,

I AM NEW to ANGULAR JS

MIssing thing is, how to load the login page.

  1. Create the new module. app.page.login, file Login.module.js file,
  2. create controller Login.controller.js file.
  3. create services Login.Services.js file.
  4. inculde this file in Index.html page.
    it loads the Login page in UI-View under the content page,

ISSUE- Side bar and top navigation appreas, ideally login page should
render fully across the page.

Solution.

  1. Create another root page or main page.

  2. if Index.html is root page then main section should be moved to
    main.html file

  3. Create folder Main , create app.page.main mdoule in Main.module.js file,
    same way add controller and services file.

  4. Inject the app.page.Main module in app.page module and

  5. Include this new .js files in Index.html files.

  6. include UI-VIEW in index.html file,(if it is not there un named
    ui-view). it will load the login page as full page.

  7. on click of login Page user State.go('Main) state to go to main.html
    file which is having main section with Side,Page top, top content and
    another UI-VIEW. which will load the Side bar, page top, and content page,
    on click of menu, it should open the views in content page.

ISSUE- it opens the views with parent UI-VIEW(index.html) not in child
view(Main.html).

There are two UI-Views (un named). one in Index.html page, another in
Main.html page.
how to load the views on click of side bar in content page(main.html). Why
it opens the views with Index.html page. Its really may be a bug or there
way to load the content inside child view(main.html).

total there are 3 UI-VIEW, a) Index.html for login page to render, b)
main.html to render the content,c) which loads submenu iteams( abstract
true).

In Blur admin there are two UI-VIEW which works fine, why it doesn't works
with 3 UI-VIEW.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Thu, Jun 16, 2016 at 10:45 PM, Brijesh Pal [email protected] wrote:

Hi,

i am progrssed in authentication part. i am able to put and get the value
of $cookies,

  1. created module(app.pages.authorization). injected into module
    app.pages(pages.module.js).

  2. created landing page(Main.html) which will have menus , Top header(user
    profile), footer, and index.html(root file). after this.(it was there in
    index.html page under body tag).

  3. added ui-view(unnamed) to landing page(main.html). that will load the
    content on click of menus in sidebar.(ladning page does't have any body
    tag) only div, other html controls required.

  4. Index.html having another ui-view(un named). under body tag. which
    loads the login into index.html(root) file.

after login page it goes to Main.html page,

ISSUE--

on click of menu in sidebar it, opens the page with parent(index.html)
file(UI-VIEW), overrides the same page, it should open views with
main.html(in same window).

Possible solution 1) named view should be used,
2) can we change sidebar position out of main section,
3) Parent UI-view scope is overriding the Main.html ui-view.

Please suggest thanks in advance.

Thanks,
Warm Regards :Brijesh Pal
Mobile : +919790752446

On Tue, Jun 14, 2016 at 7:27 AM, VAZH [email protected] wrote:

like i said, use factory/services.
put the value inside those factory/services. or you can make a session
storage factory/services.
that way, when you logging in, if valid it save values/parameters inside
factory/session. and then you can access it from another controller. you
just need to inject it.

though i dont know much about $cookies. it should work the same.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#68 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AGltbMGFH9CwPwhfE4TGtvBnEDLO04uAks5qLgqWgaJpZM4IzIz1
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants