Guillermo - paths enable/disable registration[skip ci]
This commit is contained in:
parent
a317f6a29c
commit
397246aa4b
|
@ -28,9 +28,10 @@ class GetSettingsController extends Controller {
|
||||||
'smtp-port' => Setting::getSetting('smtp-port')->getValue(),
|
'smtp-port' => Setting::getSetting('smtp-port')->getValue(),
|
||||||
'smtp-host' => Setting::getSetting('smtp-port')->getValue(),
|
'smtp-host' => Setting::getSetting('smtp-port')->getValue(),
|
||||||
'smtp-user' => Setting::getSetting('smtp-port')->getValue(),
|
'smtp-user' => Setting::getSetting('smtp-port')->getValue(),
|
||||||
|
'registration' => Setting::getSetting('registration')->getValue(),
|
||||||
'departments' => Department::getDepartmentNames(),
|
'departments' => Department::getDepartmentNames(),
|
||||||
'supportedLanguages' => Language::getSupportedLanguages(),
|
'supportedLanguages' => Language::getSupportedLanguages(),
|
||||||
'allowedLanguages' => Language::getAllowedLanguages()
|
'allowedLanguages' => Language::getAllowedLanguages(),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$settingsList = [
|
$settingsList = [
|
||||||
|
@ -42,6 +43,7 @@ class GetSettingsController extends Controller {
|
||||||
'allow-attachments' => Setting::getSetting('allow-attachments')->getValue(),
|
'allow-attachments' => Setting::getSetting('allow-attachments')->getValue(),
|
||||||
'max-size' => Setting::getSetting('max-size')->getValue(),
|
'max-size' => Setting::getSetting('max-size')->getValue(),
|
||||||
'title' => Setting::getSetting('title')->getValue(),
|
'title' => Setting::getSetting('title')->getValue(),
|
||||||
|
'registration' => Setting::getSetting('registration')->getValue(),
|
||||||
'departments' => Department::getDepartmentNames(),
|
'departments' => Department::getDepartmentNames(),
|
||||||
'supportedLanguages' => Language::getSupportedLanguages(),
|
'supportedLanguages' => Language::getSupportedLanguages(),
|
||||||
'allowedLanguages' => Language::getAllowedLanguages()
|
'allowedLanguages' => Language::getAllowedLanguages()
|
||||||
|
|
|
@ -50,6 +50,10 @@ class SignUpController extends Controller {
|
||||||
Response::respondError(ERRORS::ALREADY_BANNED);
|
Response::respondError(ERRORS::ALREADY_BANNED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!Setting::getSetting('registration')->value) {
|
||||||
|
Response::respondError(ERRORS::NO_PERMISSION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$userId = $this->createNewUserAndRetrieveId();
|
$userId = $this->createNewUserAndRetrieveId();
|
||||||
$this->sendRegistrationMail();
|
$this->sendRegistrationMail();
|
||||||
|
|
|
@ -51,3 +51,5 @@ require './staff/last-events.rb'
|
||||||
require './system/get-mail-templates.rb'
|
require './system/get-mail-templates.rb'
|
||||||
require './system/edit-mail-template.rb'
|
require './system/edit-mail-template.rb'
|
||||||
require './system/recover-mail-template.rb'
|
require './system/recover-mail-template.rb'
|
||||||
|
require './system/disable-registration.rb'
|
||||||
|
require './system/enable-registration.rb'
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
describe'/system/disable-registration' do
|
||||||
|
request('/user/logout')
|
||||||
|
Scripts.login($staff[:email], $staff[:password], true)
|
||||||
|
|
||||||
|
it 'should not disable registration if password is not correct' do
|
||||||
|
result= request('/system/disable-registration', {
|
||||||
|
csrf_userid: $csrf_userid,
|
||||||
|
csrf_token: $csrf_token,
|
||||||
|
password: 'hello'
|
||||||
|
})
|
||||||
|
|
||||||
|
(result['status']).should.equal('fail')
|
||||||
|
|
||||||
|
row = $database.getRow('setting', 'registration', 'name')
|
||||||
|
|
||||||
|
(row['value']).should.equal('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should disable registration' do
|
||||||
|
result= request('/system/disable-registration', {
|
||||||
|
csrf_userid: $csrf_userid,
|
||||||
|
csrf_token: $csrf_token,
|
||||||
|
password: $staff[:password]
|
||||||
|
})
|
||||||
|
|
||||||
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
|
row = $database.getRow('setting', 'registration', 'name')
|
||||||
|
|
||||||
|
(row['value']).should.equal('0')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not create user in database if registration is false' do
|
||||||
|
response = request('/user/signup', {
|
||||||
|
:name => 'ponzio',
|
||||||
|
:email => 'jc@ponziolandia.com',
|
||||||
|
:password => 'tequila'
|
||||||
|
})
|
||||||
|
|
||||||
|
(response['status']).should.equal('fail')
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,33 @@
|
||||||
|
describe'/system/enable-registration' do
|
||||||
|
request('/user/logout')
|
||||||
|
Scripts.login($staff[:email], $staff[:password], true)
|
||||||
|
|
||||||
|
it 'should not enable registration if password is not correct' do
|
||||||
|
result= request('/system/enable-registration', {
|
||||||
|
csrf_userid: $csrf_userid,
|
||||||
|
csrf_token: $csrf_token,
|
||||||
|
password: 'hello'
|
||||||
|
})
|
||||||
|
|
||||||
|
(result['status']).should.equal('fail')
|
||||||
|
|
||||||
|
row = $database.getRow('setting', 'registration', 'name')
|
||||||
|
|
||||||
|
(row['value']).should.equal('0')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should enable registration' do
|
||||||
|
result= request('/system/enable-registration', {
|
||||||
|
csrf_userid: $csrf_userid,
|
||||||
|
csrf_token: $csrf_token,
|
||||||
|
password: $staff[:password]
|
||||||
|
})
|
||||||
|
|
||||||
|
(result['status']).should.equal('success')
|
||||||
|
|
||||||
|
row = $database.getRow('setting', 'registration', 'name')
|
||||||
|
|
||||||
|
(row['value']).should.equal('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue