adminc: user change password
This commit is contained in:
parent
02eea315dd
commit
4c79c78e60
@ -142,11 +142,8 @@ module AuthD
|
|||||||
], read
|
], read
|
||||||
end
|
end
|
||||||
|
|
||||||
def mod_user(uid_or_login : UserID, password : String? = nil, email : String? = nil)
|
def mod_user(uid_or_login : UserID, password : String? = nil, email : String? = nil, admin : Bool? = nil)
|
||||||
request = Request::ModUser.new uid_or_login
|
request = Request::ModUser.new uid_or_login, admin, password, email
|
||||||
|
|
||||||
request.password = password if password
|
|
||||||
request.email = email if email
|
|
||||||
|
|
||||||
send_now request
|
send_now request
|
||||||
parse_message [
|
parse_message [
|
||||||
|
@ -127,6 +127,18 @@ parser = OptionParser.new do |parser|
|
|||||||
unrecognized_args_to_context_args.call parser, 1
|
unrecognized_args_to_context_args.call parser, 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
parser.on "change-password", "Change the password of a user (requires admin)." do
|
||||||
|
parser.banner = "Usage: user change-password userid"
|
||||||
|
Baguette::Log.info "Change the password of an account."
|
||||||
|
Context.command = "user-change-password"
|
||||||
|
opt_authd_login.call parser
|
||||||
|
opt_email.call parser
|
||||||
|
opt_profile.call parser
|
||||||
|
opt_help.call parser
|
||||||
|
# userid
|
||||||
|
unrecognized_args_to_context_args.call parser, 1
|
||||||
|
end
|
||||||
|
|
||||||
parser.on "delete", "Remove user." do
|
parser.on "delete", "Remove user." do
|
||||||
parser.banner = "Usage: user delete userid [opt]"
|
parser.banner = "Usage: user delete userid [opt]"
|
||||||
Baguette::Log.info "Remove user."
|
Baguette::Log.info "Remove user."
|
||||||
|
@ -53,6 +53,7 @@ class Actions
|
|||||||
def initialize(@authd)
|
def initialize(@authd)
|
||||||
@the_call["user-registration"] = ->user_registration
|
@the_call["user-registration"] = ->user_registration
|
||||||
@the_call["user-validation"] = ->user_validation # Do not require authentication.
|
@the_call["user-validation"] = ->user_validation # Do not require authentication.
|
||||||
|
@the_call["user-change-password"] = ->user_change_password
|
||||||
@the_call["user-recovery"] = ->user_recovery # Do not require authentication.
|
@the_call["user-recovery"] = ->user_recovery # Do not require authentication.
|
||||||
@the_call["user-delete"] = ->user_deletion # Do not require admin priviledges.
|
@the_call["user-delete"] = ->user_deletion # Do not require admin priviledges.
|
||||||
@the_call["user-get"] = ->user_get
|
@the_call["user-get"] = ->user_get
|
||||||
@ -191,6 +192,19 @@ class Actions
|
|||||||
puts "error: #{e.message}"
|
puts "error: #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_change_password
|
||||||
|
args = Context.args.not_nil!
|
||||||
|
login = args[0]
|
||||||
|
|
||||||
|
password : String? = nil
|
||||||
|
Baguette::Log.info "new password:"
|
||||||
|
password = Actions.ask_password
|
||||||
|
exit 1 unless password
|
||||||
|
|
||||||
|
res = authd.mod_user login, password #, email, admin
|
||||||
|
puts res
|
||||||
|
end
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
def user_mod
|
def user_mod
|
||||||
args = Context.args.not_nil!
|
args = Context.args.not_nil!
|
||||||
@ -213,7 +227,7 @@ class Actions
|
|||||||
Baguette::Log.error "This function shouldn't be used for now."
|
Baguette::Log.error "This function shouldn't be used for now."
|
||||||
Baguette::Log.error "It is way too cumbersome."
|
Baguette::Log.error "It is way too cumbersome."
|
||||||
|
|
||||||
# res = authd.add_user login, password, email, profile: profile
|
# res = authd.mod_user login, password, email, admin
|
||||||
# puts res
|
# puts res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user