user settings updated to lv and lv tests created. all tests working
This commit is contained in:
parent
24502e2667
commit
ef7b8e0bb8
26 changed files with 389 additions and 288 deletions
lib/bones73k
|
@ -172,10 +172,10 @@ defmodule Bones73k.Accounts do
|
|||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def apply_user_email(user, password, attrs) do
|
||||
def apply_user_email(user, %{"current_password" => curr_pw} = attrs) do
|
||||
user
|
||||
|> User.email_changeset(attrs)
|
||||
|> User.validate_current_password(password)
|
||||
|> User.validate_current_password(curr_pw)
|
||||
|> Ecto.Changeset.apply_action(:update)
|
||||
end
|
||||
|
||||
|
@ -247,11 +247,11 @@ defmodule Bones73k.Accounts do
|
|||
{:error, %Ecto.Changeset{}}
|
||||
|
||||
"""
|
||||
def update_user_password(user, password, attrs) do
|
||||
def update_user_password(user, %{"current_password" => curr_pw} = attrs) do
|
||||
changeset =
|
||||
user
|
||||
|> User.password_changeset(attrs)
|
||||
|> User.validate_current_password(password)
|
||||
|> User.validate_current_password(curr_pw)
|
||||
|
||||
Ecto.Multi.new()
|
||||
|> Ecto.Multi.update(:user, changeset)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue