Comments (3)
You can extend the users context easily: https://github.com/danschultzer/pow/blob/master/lib/pow/ecto/context.ex#L7-L20
In this case I wouldn't combine the two, but instead just keep the default context methods inside Pow, and create one specifically for my manager actions. It's better to have different contexts depending on how you interact with the underlying user struct. But if you do wish to change or extend how the default context is working then the above docs is how you do it!
from pow.
I wouldn't use any Pow methods, but instead create a context module for manager API calls. This can work better for security as you can limit that particular changeset to just accepting role
changes.
This is one way of setting it up:
defmodule MyApp.UserManagement do
alias MyApp.Users.User
def update_role(user, attrs) do
user
|> User.role_changeset(attrs)
|> Repo.update()
end
end
defmodule MyApp.Users.User do
# ...
def role_changeset(user_or_changeset, attrs) do
cast(user_or_changeset, attrs, [:role])
end
end
Pow.Ecto.Context
(that Pow.Operations
uses by default) is the context API for handling registration and authentication with Pow, and just that. Any other kind of operations should be moved to a dedicated context.
from pow.
I agree. To create another context is easy and manageable. But I'd like to know if there's a flexible and configurable way to achieve this.
I believe this feature will be one of frequently requested by developers. If so, how about providing Myapp.Users
context for better extensibility by default?
from pow.
Related Issues (20)
- Replacing Phoenix.Token with JWT-based for signing and verifiying of tokens HOT 1
- Unable to logout user in Pow API HOT 2
- Feature Request: Apple Passkeys HOT 1
- Pow.Plug.authenticate_user/1 performance HOT 2
- Reset password - test fails issue HOT 1
- Upgrading to Phoenix 1.7 HOT 5
- Create account without email/password using some unique ID?
- Phoenix 1.7 compilers warning HOT 1
- Maintain case when storing emails HOT 2
- Permissions issues with mnesia backend for Pow HOT 15
- Improve mix tasks
- Crash @missing_field? in Schema.ex HOT 1
- Inject values on registration HOT 2
- users_context seems to be ignored HOT 1
- Upgrading POW from 1.6 to 1.7 HOT 12
- Changeset errors into view HOT 1
- POW & LiveView - best way to implement `assigns.current_user` ? HOT 7
- Elixir 1.15 deprecation warnings HOT 1
- Persistence of stale session ids in MnesiaCache HOT 10
- Phoenix 1.6 App upgraded to 1.7 warning about layout conflicts. 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 pow.