akveo / nebular

:boom: Customizable Angular UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/nebular
MIT License
8.05k stars 1.51k forks source link

Help with Auth Module #35

Closed blankstar85 closed 6 years ago

blankstar85 commented 6 years ago

Hello,

Loving the theme. I've been reading up as much and digging into the code. I love how it has been broken out to the modules so we can update the base without really messing up our project!

I'm working on integrating the Auth module with my backend. I use node and express with passportjs for my authentication. it defaults to responding with status 200 OK as long as the server can process the message. the login failure/success is in the response json. ex:

{ "success": false, "message": { "message": "Invalid Username or Password" } }

As the above you can see it didn't work, but the authentication module lets it through as a successful login. if i looking https://github.com/akveo/nebular/blob/master/src/framework/auth/providers/email-pass-auth.provider.ts authenticate method I see that as long as always fail is false and as long as the server response is ok, it will be a successful login.

I'm still learning, so thank you in advance for your help. What is the best way to have it look at the success in the response?

Update: Reading the code more and looking at it (after a break) It looks like i want to write my own provider copying email-pass-auth.provider.ts and then modify as such for the authenticate function line 193 code below starts on line 204 capture

Edit: I updated the code to correctly reflect accessing json success message, added png of code with highlighted changes, seems to be working, but when passport successfully logs in it just gives the message component. Still looking, at this point, the question would be what is the better way to handle this. Thanks!

Edit: Disregard entirely, I took a chance to look back at old code, before I had a decent grasp of Typescript angular etc. I figured out my issue I updated my response with a status reflecting not authorized and actually fixed my json so there aren't message:{message:}.

nnixaa commented 6 years ago

@blankstar85 glad to hear you resolved it!

wilson-young commented 6 years ago

@blankstar85 , can i know how u configure auth in project? i have try installing ngx-admin, but i am stuck in setup the auth part. i also have copied the original source code from /framework/auth to my project directory.