You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
740 B
32 lines
740 B
5 years ago
|
class Gitea::Users::RegisterService < Gitea::APIService
|
||
|
REQUEST_URL = [Gitea::APIService.base_url, "/admin/users"].join('').freeze
|
||
|
|
||
|
def initialize(options = {})
|
||
|
options.each_pair do |key, value|
|
||
|
instance_variable_set("@#{key}", value)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def call
|
||
|
response = Gitea.client.post do |req|
|
||
|
req.url "#{REQUEST_URL}"
|
||
|
req.headers['Content-Type'] = 'application/json'
|
||
|
req.body = user_params.to_json
|
||
|
end
|
||
|
Gitea::APIService.render_status(response)
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
attr_reader :email, :username, :password
|
||
|
|
||
|
def user_params
|
||
|
{
|
||
|
email: email,
|
||
|
username: username,
|
||
|
password: password,
|
||
|
must_change_password: false #允许不更改秘密就可以登录
|
||
|
}
|
||
|
end
|
||
|
end
|