riverrun / phauxth

Not actively maintained - Authentication library for Phoenix, and other Plug-based, web applications
409 stars 20 forks source link

Invalid credentials #53

Closed wernerlaude closed 5 years ago

wernerlaude commented 6 years ago

Hi. Thanks for phauxth.. Where can I find && alter this message: Invalid credentials Cant find it..

Greetings

riverrun commented 6 years ago

Hi.

You need to create a custom UserMessages module - see lib/phauxth/user_messages.ex and test/user_messages_test.exs for examples and documentation - and then set the user_messages value in the config to use your custom UserMessages module.

Let me know if you have any further questions.

wernerlaude commented 6 years ago

Hi David. thanks for your reply.

As I am totally new to phoenix.. need some more help. I copied:

defmodule MyApp.UserMessages do use Phauxth.UserMessages.Base import MyApp.Gettext def default_error, do: gettext "Nix da!" end

created a file user_messages.ex But where to put it?

Wherever I try I get: module MyApp.Gettext is not loaded and could not be found Sorry to bother you..

Werner

Am 25.02.2018 um 10:45 schrieb David Whitlock notifications@github.com:

UserMessages

riverrun commented 6 years ago

No problem. I will add an example to the example app a bit later on today and then send you a link.

riverrun commented 6 years ago

If you look at the example project, in the lib/forks_the_egg_sample_web directory, there is a gettext.ex file. You need a similar file in your project. Then in the same directory, add your user_messages.ex file.

One last thing you need to do is add the following line to your config/config.exs file:

config :phauxth, user_messages: MyApp.UserMessages

Let me know if that works

wernerlaude commented 6 years ago

Thanks for helping..David.. I will check the next days and give you notice..

Greetings from Munich. Werner Werner Laude - WebDevelopment - München

Am 27.02.2018 um 07:33 schrieb David Whitlock notifications@github.com:

config :phauxth, user_messages: MyApp.UserMessages

wernerlaude commented 6 years ago

Thanks David.. Started again to learn Phoenix.. Now I better get the idea..and it works fine.

Hope you don't mind bothering you with an other point: Authorization ID check works perfect with user. But how to check other models like projects? As the current_user.id is not equal the project.id but the project.user_id (belongs_to user) Great to have an example too.

Thanks for your gentle support Werner

riverrun commented 6 years ago

In the Authorization page in the wiki, there are a lot of examples of plugs that you can write. You would need to write a plug to to check that current_user.id equals the project.user_id, and then use that plug when you need authorization for projects.

In this example on line 39, you might be able to achieve what you want by replacing %{"id" => id} with %{"user_id" => user_id}.

wernerlaude commented 6 years ago

Thanks David for taking time.. no need to hurry..

For answering later, when you have time and mood…not urgent .. How can I address in the user_messages.ex the success messages: You are logged in! You are logged out. ? Tried but..

Greetings from Munich.. Werner

Am 22.05.2018 um 07:55 schrieb David Whitlock notifications@github.com:

In the Authorization page in the wiki, there are a lot of examples of plugs that you can write. You would need to write a plug to to check that current_user.id equals the project.user_id, and then use that plug when you need authorization for projects.

In this example https://github.com/riverrun/phauxth-example/blob/master/lib/forks_the_egg_sample_web/controllers/authorize.ex on line 39, you might be able to achieve what you want by replacing %{"id" => id} with %{"user_id" => user_id}.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/riverrun/phauxth/issues/53#issuecomment-390871711, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC5hZy2nqOidZHQ3vWbHAKxS-aODwJJks5t06hQgaJpZM4SSB0U.

Werner Laude - WebDevelopment - München mail@laude.me mailto:mail@laude.me | +49 178 135 34 39 <tel:+49 178 135 34 39>