37 lines
1.1 KiB
Ruby
37 lines
1.1 KiB
Ruby
#coding=utf-8
|
|
|
|
module Trustie
|
|
module Gitlab
|
|
module Helper
|
|
def change_password(uid, en_pwd, salt)
|
|
options = {:encrypted_password=>en_pwd, :password_salt=>salt}
|
|
self.g.put("/users/ext/#{uid}", :body => options)
|
|
# g.edit_user(uid, :encrypted_password=>en_pwd, :password_salt=>salt)
|
|
end
|
|
|
|
def add_user(user)
|
|
u = nil
|
|
begin
|
|
u = self.g.get("/users?search=#{user.mail}").first
|
|
unless u
|
|
u = self.g.create_user(user.mail,
|
|
user.hashed_password,
|
|
name: user.show_name,
|
|
username: user.login,
|
|
confirm: "true")
|
|
user.gid = u.id
|
|
end
|
|
change_password(u.id, user.hashed_password, user.salt)
|
|
rescue => e
|
|
puts e
|
|
end
|
|
return u
|
|
end
|
|
|
|
def del_user(user)
|
|
## gitlab unimplement
|
|
end
|
|
|
|
end
|
|
end
|
|
end |