This is a gold mine for user auth concept. Well done!
@ahmad.mozaffar3 жыл бұрын
That comment made my day
@amierulbasyaryusoff2459 Жыл бұрын
Your tutorial was a game-changer for me! I had been banging my head against the wall trying to figure out how to turn a scaffolded identity into a Web API, but your step-by-step instructions made it all so clear. Thank you for making such a difference in my learning journey.
@ahmad.mozaffar Жыл бұрын
This comment made my day, thank you so much. Happy that it was helpful for you!
@andresbeltran5779 Жыл бұрын
Finished series Yujuuuuu, thanks for sharing
@ahmad.mozaffar Жыл бұрын
Hey Andres, so happy that you liked the course, I hope it was beneficial for you
@abelghaniE2 жыл бұрын
We thank you for the quality of the explanations. Continue
@ahmad.mozaffar2 жыл бұрын
Thank you so much for that amazing feedback!! the best is yet to come
@sale16093 жыл бұрын
Hello Ahmad, truly amazing! I never like a video on youtube but this course really compelled me to like all your videos. The content is perfectly created for junior and senior developers. Thumbs up. I would love to know how we can make these APIs scalable and efficient in performance. Thanks and keep up this great work.
@ahmad.mozaffar3 жыл бұрын
Heey, Thank you so much for such a kind and encouraging comment, that really made my day, sorry for late reply and thank you so much again, regarding you question I will make sure to have a video about how to develop a full API very soon which will cover all the mentioned things Thanks again
@cdv1303 жыл бұрын
You should add a Decode(token) and a Encode(token) helper functions in your UserService class, to cut down on the copy pasta! Other than that, I really liked this!
@ahmad.mozaffar3 жыл бұрын
You are totally right, so happy that you liked it
@diamondchirisa15904 жыл бұрын
Thanks bro. Watched all the videos of the playlist. I deserve a certificate of completion. lol
@ahmad.mozaffar4 жыл бұрын
Thanks man Haha that's nice I will think of it ;-P
@diamondchirisa15904 жыл бұрын
@@ahmad.mozaffar No worried bro. Do you have any tutorial on claims, roles and policies relating to this course?
@ahmad.mozaffar4 жыл бұрын
Diamond Chirisa Unfortunately but I don’t have yet
@DươngPhạmTùng-l4t Жыл бұрын
It is so useful, thank bro!
@ahmad.mozaffar Жыл бұрын
Thanks for your nice comment
@MihaiMoisei4 жыл бұрын
Thanks for all.
@ahmad.mozaffar4 жыл бұрын
Mihai Moisei Glad to help
@umidzeynalov943 жыл бұрын
Hi! I Learning more... Thanks
@ahmad.mozaffar3 жыл бұрын
Super super happy to hear that!!!
@NK-xw4uu3 жыл бұрын
Can you tell me whether you could have used static page instead of razor page?
@ahmad.mozaffar3 жыл бұрын
Here just because we are using ASP MVC App we need to embed some C# code in it and this is why we have used razor but you can use HTML with some JS to fetch the token from the URL and put in the form
@leaguefun4 жыл бұрын
Awesome tutorial !!! By the way, I find some difficulties to deploy it to be used in IIS, would you mind to provide some suggestions? thanks.
@ahmad.mozaffar4 жыл бұрын
That's so nice of you Thanks for your feedback Of course I'm here to help, just let me know the issue!
@leaguefun4 жыл бұрын
@@ahmad.mozaffar I published the project as self-contained folder through VS, and put the folder inside the iis folder i.e. inetpub/wwwroot/identity, change the application pool into .NET CLR with not managed code, however, when i tried to access the api endpoint, its returned 505, am i doing something wrong ? thanks in advance :D
@ahmad.mozaffar4 жыл бұрын
Great, could you just please push a screenshot of the error so I can have more details You can share the picture on Twitter @AhmadMozaffar99 Thanks
@leaguefun4 жыл бұрын
@@ahmad.mozaffar You are nice, I had twitted the screenshots, thanks :D
@ahmad.mozaffar4 жыл бұрын
Thanks, I have checked it
@sekars62234 жыл бұрын
Thanks for Very good contents .
@minhnguyenquang17242 жыл бұрын
This video is so amazing. How can I add external login like Google or Facebook? Thank you very much.
@ahmad.mozaffar2 жыл бұрын
Thanks for nice feedback, yeah actually you can do that easier using Identity services like Azure Active Directory B2C, as it's easier to complete
@venkateshsiddagani37743 жыл бұрын
Hi Sir, When I was adding services.AddIdentity.... I was getting error identitybuilder doesn't contain a definition for AddEntitityFrameworkStore and no accessible extension method AddEntityFrameworkStores accepting a first argument of type IdentityBuilder. Can you pls help me here
@ahmad.mozaffar3 жыл бұрын
Hi dear You should use AddScoped instead of AddIdentity
@TheAhmedasdasd4 жыл бұрын
Hi, is that the last video in that series?
@ahmad.mozaffar4 жыл бұрын
ahmed ibrahiem Yes That’s the last one If you are interested in more complex authentication scenarios I highly recommend this kzbin.info/www/bejne/al6VqISNhLmZbMU
@souravbhattacharjee39944 жыл бұрын
Also, how can I set an expiration policy on the password reset/ email confirmation token?
@ahmad.mozaffar4 жыл бұрын
Surely you can very easily services.Configure(options => options.TokenLifespan = TimeSpan.FromHours(3));
@souravbhattacharjee39944 жыл бұрын
@@ahmad.mozaffar Thanks
@ahmad.mozaffar4 жыл бұрын
Sourav Bhattacharjee Pleasure
@codigodavinchi2 жыл бұрын
I know this question is out of the scope of the video but, Do you know how can I add an Alert to show the result in the password change form? I appreciate any information you give me... Thanks!
@ahmad.mozaffar2 жыл бұрын
Hi, thanks for reaching out, could you explain a little bit more please
@codigodavinchi2 жыл бұрын
Hi @@ahmad.mozaffar I mean, I'm trying to figure out how to show the result of the password change in a good looking way instead of the plain json string result from te API so I want to create an alert, like a window, to show that result
@nizamarif58253 жыл бұрын
Hi, I'm following your example in trying to implement password reset for a web api project consumed by a mobile app . However, I get error 405 when I post the form to ResetPassword endpoint. Yes I've attributed the endpoint point with HttpPost and I make sure that I have the value "post" in method tags in my Razor page. Do you have any idea why, when calling the endpoint for ResetPassword I get this error? When testing with postman it works well.
@ahmad.mozaffar3 жыл бұрын
Hi dear Thanks for your interest 405 means you are send the wrong format from the client or Method not allowed Make sure in the controller to decorate your parameter with [FromBody] And to send a post request correctly from your mobile app
@nizamarif58253 жыл бұрын
@@ahmad.mozaffar thanks for your answer. The call to ResetPassword is made from a browser using a post method. And yes the parameter is decorated with [FromBody].
@ahmad.mozaffar3 жыл бұрын
@@nizamarif5825 could you please share with me the code from the client side via my Twitter account @AhmadMozaffar99
@nizamarif58253 жыл бұрын
@@ahmad.mozaffar I managed to find the error. Didn' add the slash characters to the action method value which meant I got a relative url. Thanks for your time.
@ahmad.mozaffar3 жыл бұрын
@@nizamarif5825 Happy for that Thanks
@MuhammadAsgir-fp1ee Жыл бұрын
Sir I am working in MVC core 3.1 this API Code, will work for me. ???
@ahmad.mozaffar Жыл бұрын
Hi, yes the concepts are the same just little adjustments and version of the libraries
@Artavazd.kirakosyan5 жыл бұрын
thanks for a good contents
@fernandoschilipackramos55414 жыл бұрын
Hi, how can I get the user name when he logs in? I mean on postman once a user successfully Login there are 3 fields "message", "isSuccess" ,"Errors", "expireDate". In my case, I want to return his name as well, how can I return the claims "Name" (this is a column I added on my table aspnetUsers). I'm already getting this info once he registers in the API now I just want to get his name once he logins(so I can use this info on my app to show the username), should I extend this class to exhibit his name or try a different approach? Thanks for the videos and the kindness to reply :)
@ahmad.mozaffar4 жыл бұрын
Hi dear thanks for reaching out you can add a new property or the best way to do this I have not mentioned that in the videos but I will make a new video very soon about that which is add it to the claims of the access tokens when you set the email and other properties Then in the client you should decode the access token so you get a list of claims you put like email, name, phone ..... This link will help you in the decoding process after you receive the token from the server do this in the client developer.okta.com/blog/2019/06/26/decode-jwt-in-csharp-for-authorization
@fernandoschilipackramos55414 жыл бұрын
@@ahmad.mozaffar Alright thanks a lot! Looking forward to these new videos :)
@ahmad.mozaffar4 жыл бұрын
Fernando Schilipack Ramos You are must welcome mate
@shect14 жыл бұрын
good video but just one note, you should always return Ok with the same message even if you don't find an account with that email. Your implementation let's a hacker know if there's an account with that email in the system.
@ahmad.mozaffar4 жыл бұрын
Yeah correct Will be taken into condensation thanks a lot for your feedback and your interest
@Rizzwan73 жыл бұрын
Nice video
@ahmad.mozaffar3 жыл бұрын
Thanks!!
@nirajdahal50194 жыл бұрын
Sir if i had to add login providers like facebook, google or linkedin in this same project. How do i do that? I couldn't find a good resources for this.
@ahmad.mozaffar4 жыл бұрын
Thank you so much for reaching out Adding such a Login provider probably you should go with it manually from scratch you write the code that validate the access token against Facebook for example, so the best way to add them and make them goes in reality if you have to implement this the best way to is go with Azure Active Directory B2C it's already implemented and to know more about this you can check the videos from 07 until 12 here kzbin.info/www/bejne/novXdIacbMqLZ8k And to implement the external auth providers just check this blog docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-add-identity-providers
@mahmoudtaha54924 жыл бұрын
Thank you for this great work . I have applied this and it works smoothly ,but when I use role it gives me "403 forbidden" status code while this role is recorded in database .could you help me out in this issue ?
@ahmad.mozaffar4 жыл бұрын
mahmoud taha The role is existing and it’s applied for the logged in User
@mahmoudtaha54924 жыл бұрын
@@ahmad.mozaffar i mean when i try to add role like "Admin" to existing user and then i use [Authorize(Roles="Admin")] on specific resource i get "403 forbidden"
@conaxlearn85663 жыл бұрын
This assumes that both front end and API are developed by same group of people. If they are not developed by the same group of people, then usually it would be the front end team's responsibility to send the email with the Reset Password page URL isn't it? Because the API developer would not have any idea where they need to redirect the end user to.
@ahmad.mozaffar3 жыл бұрын
Somehow yes But at the end you can redirects the user to page different than the app I mean the reset password could happen in a separated website, and let the client-side UWP in this case just opens that webpage to reset the password
@amer5704 жыл бұрын
many thanks
@ahmad.mozaffar4 жыл бұрын
Thanks for your support
@souravbhattacharjee39944 жыл бұрын
Thanks for the videos. How can I sign off the user so that the token expires immediately?
@ahmad.mozaffar4 жыл бұрын
Thanks for reaching out This is possible but a little bit hard Usually logout just removes the access token from the client, also the expiry date for the token should be too short for example 5 mins and make a refresh token endpoint You can find more about this here stackoverflow.com/questions/45748732/could-we-destroy-invalidate-jwt-token-in-asp-net-core
@souravbhattacharjee39944 жыл бұрын
@@ahmad.mozaffar I understand, thanks
@ahmad.mozaffar4 жыл бұрын
Sourav Bhattacharjee Happy for that
@poojamaurya59774 жыл бұрын
where I can find a UserManager class?
@ahmad.mozaffar4 жыл бұрын
Hi dear It's already there in the ASP.NET Identity when you install it
@mohamadhussen99335 жыл бұрын
gooood work thank
@fernandoschilipackramos55414 жыл бұрын
Hi it's me again... haha how can I consume the endpoint "ForgetPassword" into my project? been struggling with it. I know how to test in on postman but kinda couldn't implement it yet on my mobile project, could u help? How can i create the method to consume it?! I'm using xamarin forms, the others endpoints is already working, login and register, but for forgetpassword seems different on my ApiService class
@fernandoschilipackramos55414 жыл бұрын
public static async Task ForgetPassword(string email) { var forgetpassword = new ForgetPassword() { Email = email, }; var httpClient = new HttpClient(); var json = JsonConvert.SerializeObject(forgetpassword); var content = new StringContent(json, Encoding.UTF8, "application/json"); var resposta = await httpClient.PostAsync(AppSettings.ApiUrl + "api/conta/forgetpassword?email=", content); if (!resposta.IsSuccessStatusCode) return false; else return true; } I tried this, but i don't think that's the right thing
@fernandoschilipackramos55414 жыл бұрын
I created a page to receive this user email so when he input the data it will send to my API, just dunno how to do it xD
@ahmad.mozaffar4 жыл бұрын
Welcome back again, Thank you so much for your interest Regarding your issue what is the error you get exactly ?
@fernandoschilipackramos55414 жыл бұрын
@@ahmad.mozaffar Hey there! I did manage to work, It wasn't working because the property wasn't referring to anything i used the Email property of LoginModel class instead of creating a specific class just to "ForgetPassword" method & also i made some minor changes staying like this: public static async Task ForgetPassword(string email) { var forgetpassword = new LoginModel() { Email = email, }; var httpClient = new HttpClient(); var json = JsonConvert.SerializeObject(forgetpassword); var content = new StringContent(json, Encoding.UTF8, "application/json"); var resposta = await httpClient.PostAsync(AppSettings.ApiUrl + $"api/conta/forgetpassword?email={email}", content); if (!resposta.IsSuccessStatusCode) return false; else return true; }
@ahmad.mozaffar4 жыл бұрын
@@fernandoschilipackramos5541 That a very good news, good luck dear
@sandeepbhor044 жыл бұрын
thanks for the contents
@ahmad.mozaffar4 жыл бұрын
Sandeep Bhor Thank you
@yunusserter4 жыл бұрын
Thanks
@hosnimahdhi65292 жыл бұрын
Great, how to access to resources (data) with own token (not any valid token) 🙂
@ahmad.mozaffar2 жыл бұрын
Thanks for your feedback, could you please explain a bit more?
@burakdogan68562 жыл бұрын
you can add already registererd validation to your register function var alreadyRegistered = await _userManager.FindByEmailAsync(model.Email); if (alreadyRegistered != null) { return new UserManagerResponse { Message = "This user is already registered", IsSuccess = false, }; }