Skip to content
Permalink
Browse files

회원 기본설정, 가입설정 통합

  • Loading branch information...
woongbin committed Jun 11, 2019
1 parent 6e0f401 commit 9716139a85eaf5d40a542e3ae65ab792c084c6bf
@@ -102,15 +102,14 @@ public function getRegister(Request $request)
);
}
$config = app('xe.config')->get('user.join');
$config = app('xe.config')->get('user.common');
// 가입 인증을 사용하지 않을 경우, 곧바로 회원가입 폼 출력
if (!$config->get('guard_forced', false) || $request->get('token')) {
return $this->getRegisterForm($request);
}
return \XePresenter::make('register.index');
}
/**
@@ -121,7 +120,7 @@ public function getRegister(Request $request)
*/
protected function getRegisterForm(Request $request)
{
$config = app('xe.config')->get('user.join');
$config = app('xe.config')->get('user.common');
// 활성화된 가입폼 가져오기
$parts = $this->handler->getRegisterParts();
@@ -202,7 +201,7 @@ public function postRegister(Request $request)
);
}
$config = app('xe.config')->get('user.join');
$config = app('xe.config')->get('user.common');
// 활성화된 가입폼 가져오기
$parts = $this->handler->getRegisterParts();
@@ -250,7 +249,7 @@ public function postRegister(Request $request)
*/
protected function checkJoinable()
{
return XeConfig::getVal('user.join.joinable') === true;
return XeConfig::getVal('user.common.joinable') === true;
}
/**
@@ -330,7 +329,7 @@ public function validateEmail(Request $request)
$this->validate($request, [ 'email' => 'email' ]);
// 인증 요청중인 이메일이 있는지 확인
$useEmailConfirm = app('xe.config')->getVal('user.join.guard_forced') === true;
$useEmailConfirm = app('xe.config')->getVal('user.common.guard_forced') === true;
if ($useEmailConfirm) {
if ($request->user()->getPendingEmail() !== null) {
throw new PendingEmailAlreadyExistsException();
@@ -55,7 +55,7 @@ public function index()
{
$groups = $this->groups->with('userCountRelation')->orderBy('created_at')->get();
$config = app('xe.config')->get('user.join');
$config = app('xe.config')->get('user.common');
$joinGroup = $config->get('joinGroup');
return XePresenter::make('user.settings.group.index', compact('groups', 'joinGroup'));
@@ -152,7 +152,7 @@ public function updateJoinGroup(Request $request)
$groupId = $request->get('join_group');
$joinConfig = \app('xe.config')->get('user.join');
$joinConfig = \app('xe.config')->get('user.common');
$joinConfig->set('joinGroup', $groupId);
\app('xe.config')->modify($joinConfig);
@@ -175,17 +175,14 @@ public function destroy(Request $request)
{
$groupIds = $request->get('id');
$joinConfig = \app('xe.config')->get('user.join');
$joinConfig = \app('xe.config')->get('user.common');
$joinGroup = $joinConfig->get('joinGroup');
$groups = $this->groups->query()->whereIn('id', $groupIds)->get();
XeDB::beginTransaction();
try {
foreach ($groups as $group) {
if($joinGroup !== $group->id) {
if ($joinGroup !== $group->id) {
$this->groups->delete($group);
}
}
@@ -46,11 +46,67 @@ public function __construct()
$this->users = app('xe.users');
}
/**
* edit user setting
*
* @param CaptchaManager $captcha CaptchaManager instance
* @param UserHandler $handler UserHandler instance
*
* @return mixed|\Xpressengine\Presenter\Presentable
*/
public function editSetting(CaptchaManager $captcha, UserHandler $handler)
{
$config = app('xe.config')->get('user.common');
$parts = $handler->getRegisterParts();
$activated = array_keys(array_intersect_key(array_flip($config->get('forms', [])), $parts));
$parts = collect($parts)->partition(function ($part, $key) use ($activated) {
return in_array($key, $activated) || $part::isImplicit();
});
$parts->splice(0, 1, [array_merge(array_flip($activated), $parts->first()->all())]);
return XePresenter::make(
'user.settings.setting.common',
compact('config', 'captcha', 'parts')
);
}
/**
* update user setting
*
* @param Request $request request
* @param CaptchaManager $captcha CaptchaManager instance
*
* @return \Illuminate\Http\RedirectResponse
*/
public function updateSetting(Request $request, CaptchaManager $captcha)
{
$inputs = $request->except('_token');
$config = app('xe.config')->get('user.common');
if ($inputs['useCaptcha'] === 'true' && !$captcha->available()) {
throw new ConfigurationNotExistsException();
}
$inputs['forms'] = array_keys(array_get($inputs, 'forms', []));
$inputs['guard_forced'] = $inputs['guard_forced'] === 'true';
foreach ($inputs as $key => $val) {
$config->set($key, $val);
}
app('xe.config')->modify($config);
return redirect()->back()->with('alert', ['type' => 'success', 'message' => xe_trans('xe::saved')]);
}
/**
* get Common setting
*
* @param CaptchaManager $captcha CaptchaManager instance
* @return \Xpressengine\Presenter\Presentable
*
* @deprecated since 3.0.2 instead use editSetting
*/
public function editCommon(CaptchaManager $captcha)
{
@@ -68,6 +124,8 @@ public function editCommon(CaptchaManager $captcha)
* @param Request $request request
* @param CaptchaManager $captcha CaptchaManager instance
* @return \Illuminate\Http\RedirectResponse
*
* @deprecated since 3.0.2 instead use editSetting
*/
public function updateCommon(Request $request, CaptchaManager $captcha)
{
@@ -90,6 +148,8 @@ public function updateCommon(Request $request, CaptchaManager $captcha)
*
* @param CaptchaManager $captcha CaptchaManager instance
* @return \Xpressengine\Presenter\Presentable
*
* @deprecated since 3.0.2 instead use editSetting
*/
public function editJoin(CaptchaManager $captcha, UserHandler $handler)
{
@@ -105,16 +165,17 @@ public function editJoin(CaptchaManager $captcha, UserHandler $handler)
return XePresenter::make(
'user.settings.setting.join',
compact('config','captcha', 'parts')
compact('config', 'captcha', 'parts')
);
}
/**
* update Join setting
*
* @param Request $request request
* @return \Illuminate\Http\RedirectResponse
*
* @deprecated since 3.0.2 instead use editSetting
*/
public function updateJoin(Request $request)
{
@@ -333,7 +333,7 @@ public function addMail(Request $request)
$this->validate($request, ['address' => 'email|required'], [], ['address' => xe_trans('xe::email')]);
// 이미 인증 요청중인 이메일이 있는지 확인한다.
$useEmailConfirm = app('xe.config')->getVal('user.join.guard_forced') === true;
$useEmailConfirm = app('xe.config')->getVal('user.common.guard_forced') === true;
if ($useEmailConfirm) {
if ($request->user()->getPendingEmail() !== null) {
$e = new PendingEmailAlreadyExistsException();
@@ -90,7 +90,7 @@ public function render()
*/
public function edit($view)
{
$useEmailConfirm = app('xe.config')->getVal('user.join.guard_forced') === true;
$useEmailConfirm = app('xe.config')->getVal('user.common.guard_forced') === true;
app('xe.frontend')->html('user.settings.loadScript')->content(
"<script>
@@ -153,35 +153,29 @@
'display' => true,
'ordering' => 100
],
'user.setting.join' => [
'title' => 'xe::joinSettings',
'description' => '',
'display' => true,
'ordering' => 200
],
'user.setting.terms' => [
'title' => 'xe::termsSettings',
'description' => '',
'display' => true,
'ordering' => 300
'ordering' => 200
],
'user.setting.skin' => [
'title' => 'xe::skinSettings',
'description' => '',
'display' => true,
'ordering' => 400
'ordering' => 300
],
'user.setting.field' => [
'title' => 'xe::dynamicFieldSettings',
'description' => '',
'display' => true,
'ordering' => 500
'ordering' => 400
],
'user.setting.menu' => [
'title' => 'xe::toggleMenuSettings',
'description' => '',
'display' => true,
'ordering' => 600
'ordering' => 500
],
'contents' => [
'title' => 'xe::contents',
@@ -142,7 +142,7 @@ protected function getToken($id)
*/
protected function isEnabled()
{
return $this->service('xe.config')->get('user.join')->get('guard_forced', false);
return $this->service('xe.config')->get('user.common')->get('guard_forced', false);
}
/**
@@ -79,7 +79,7 @@ public function install()
$table->string('user_id', 36)->comment('user ID');
$table->timestamp('created_at')->nullable()->comment('created date');
$table->unique(['group_id','user_id']);
$table->unique(['group_id', 'user_id']);
$table->index('group_id');
$table->index('user_id');
});
@@ -99,7 +99,7 @@ public function install()
$table->timestamp('updated_at')->nullable()->comment('updated date');
$table->primary('id');
$table->unique(['provider','account_id']);
$table->unique(['provider', 'account_id']);
});
Schema::create('user_email', function (Blueprint $table) {
@@ -183,8 +183,7 @@ public function installed()
{
DB::table('config')->insert([
['name' => 'user', 'vars' => '[]'],
['name' => 'user.common', 'vars' => '{"secureLevel":"low","useCaptcha":false,"webmasterName":"webmaster","webmasterEmail":"webmaster@domain.com"}'],
['name' => 'user.join', 'vars' => '{"joinable":true}'],
['name' => 'user.common', 'vars' => '{"secureLevel":"low","useCaptcha":false,"webmasterName":"webmaster","webmasterEmail":"webmaster@domain.com", "joinable":true}'],
['name' => 'toggleMenu@user', 'vars' => '{"activate":["user\/toggleMenu\/xpressengine@profile","user\/toggleMenu\/xpressengine@manage"]}']
]);
}
@@ -209,12 +208,73 @@ public function init()
'description' => 'sub user group'
]
);
$joinConfig = app('xe.config')->get('user.join');
$joinConfig = app('xe.config')->get('user.common');
$joinConfig->set('joinGroup', $joinGroup->id);
app('xe.config')->modify($joinConfig);
// set admin's group
auth()->user()->joinGroups($joinGroup);
}
/**
* check updated
*
* @param null $installedVersion installed version
*
* @return bool
*/
public function checkUpdated($installedVersion = null)
{
if ($this->checkNeedMergeConfig() == true) {
return false;
}
return true;
}
/**
* run update
*
* @param null $installedVersion installed version
*
* @return void
*/
public function update($installedVersion = null)
{
if ($this->checkNeedMergeConfig() == true) {
$this->mergeConfig();
}
}
/**
* check need user setting merge(common, join)
*
* @return bool
*/
private function checkNeedMergeConfig()
{
return app('xe.config')->get('user.join') !== null ? true : false;
}
/**
* run user setting merge(common, join)
*
* @return void
*/
private function mergeConfig()
{
$commonConfig = app('xe.config')->get('user.common');
$joinConfig = app('xe.config')->get('user.join');
$commonConfigAttribute = $commonConfig->getPureAll();
$joinConfigAttribute = $joinConfig->getPureAll();
foreach ($joinConfigAttribute as $name => $value) {
$commonConfigAttribute[$name] = $value;
}
app('xe.config')->put('user.common', $commonConfigAttribute);
app('xe.config')->remove($joinConfig);
}
}

0 comments on commit 9716139

Please sign in to comment.
You can’t perform that action at this time.