Comments (3)
@x19chen OpenIddict uses ASP.Net Core Identity for user management. You wouldn't necessarily use OpenIddict-ui to allow a user to change their own password; openiddict-ui is for an admin role not a user role.
You can most likely use some of the existing ASP.Net Core Identity functionality to do this. You would just need to write an api endpoint that allows a user to change their password similar to how the existing ASP.Net Core Identity functionality does it.
If you've generated all the Identity code for your project you should have a ChangePassword page somewhere in your solution. For example there is a Change Password page which is most likely located under Areas/Identity/Pages/Account/Manage/ChangePassword. You can see how this is done via the existing ASP.Net Core web application using the following code:
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
var changePasswordResult = await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword);
if (!changePasswordResult.Succeeded)
{
foreach (var error in changePasswordResult.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
}
return Page();
}
await _signInManager.RefreshSignInAsync(user);
_logger.LogInformation("User changed their password successfully.");
StatusMessage = "Your password has been changed.";
return RedirectToPage();
}
}
All you will need to do is create an api endpoint that requires authentication and allows the authenticated user to pass in the data to change their password.
Let me know if this helps.
-Robert
from openiddict-ui.
@browrp Thanks for answering the question of @x19chen. I couldn't have done it better 👍.
@x19chen For some inspiration you could have a look here or as @browrp mentioned have a look at ASP.NET Core Identity samples.
Have a nice weekend both.
Thomas
from openiddict-ui.
@browrp @thomasduft
Thanks for your answer, that was indeed helpful.
It actually confirms my suspicion that I have to create another API for that and the example is clear.
Enjoy your weekend.
Xiaoyang
from openiddict-ui.
Related Issues (18)
- UI Views request HOT 1
- Excuse me, I want to ask about using docker with your project HOT 2
- Add possibility to use api without ADMIN role HOT 5
- CRUD user profile HOT 4
- Allow generic types for IdentityUser key HOT 2
- IApplicationService.GetApplicationsAsync doesn't fill Permissions and RedirectUris HOT 3
- IApplicationService.UpdateAsync corrupts ClientSecret HOT 3
- Separate all related Identity api's and code in own projects
- Infinit loop. Data is not storing in session storage. it call the authorization again and again. HOT 1
- Remove dependency to Microsoft.AspNetCore.Mvc.Core HOT 2
- Integration test for the private resource API
- deploy to production HOT 1
- sql server HOT 3
- Register Link navigates to api/accounts/register
- No nuget after merge of Pull request #5 HOT 2
- How can I add more scopes? HOT 9
- Excuse me, I want to ask about database update HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openiddict-ui.