What is the proper way to log in users using Angular & Express?

前端 未结 2 1185
执笔经年
执笔经年 2021-01-30 14:16

I\'m building a simple web site where I\'d like to let users log in using Facebook, and then show a page with customized items based on whether or not they\'re logged in. ie if

2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 14:47

    To complete the @wpalahnuk answer you have to create a service or factory to deal the authentication and an httpInterceptor to intercept the response send by the server for know if the user is log or not (checking the staus code 401).

    For the Express part you have to use the awesome passport node module to deal the server side authentication.

    You have all the details here : https://vickev.com/#!/article/authentication-in-single-page-applications-node-js-passportjs-angularjs

    This article is really great, Brad Green (Engineering Director at Google for AngularJS) adivse me this post.

    Hope it Helps.

    If you want to know more things about security in Angular you have just to ask and i'll we be really happy to help you.

提交回复
热议问题