forked from projects/fipamo
update member info from settings
setting sync is working but member data was not being updated in the folks file or in the current active session, so that's been addressed still need to turn on avatar updating as well, but that is tied to updating the settings page, so that will be handled when image uploads for that area are reactivated
This commit is contained in:
parent
064407aa88
commit
8c375e6ba1
8 changed files with 41 additions and 16 deletions
|
@ -4,11 +4,11 @@ namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Services\SettingsService;
|
use App\Services\Data\SettingsService;
|
||||||
use App\Services\RenderService;
|
use App\Services\Assets\RenderService;
|
||||||
use App\Services\MaintenanceService;
|
use App\Services\Upkeep\MaintenanceService;
|
||||||
use App\Interfaces\MemberRepositoryInterface;
|
use App\Interfaces\MemberRepositoryInterface;
|
||||||
use App\Services\AssetService;
|
use App\Services\Assets\AssetService;
|
||||||
|
|
||||||
class SettingsAPIController extends Controller
|
class SettingsAPIController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,9 @@ class SettingsAPIController extends Controller
|
||||||
public function sync(Request $request)
|
public function sync(Request $request)
|
||||||
{
|
{
|
||||||
$body = json_decode($request->getContent());
|
$body = json_decode($request->getContent());
|
||||||
|
//update member if needed
|
||||||
|
$this->member->update($body->member);
|
||||||
|
//sync settings
|
||||||
$result = $this->settings->sync($body);
|
$result = $this->settings->sync($body);
|
||||||
return response()->json($result)->header('Content-Type', 'application/json');
|
return response()->json($result)->header('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ interface MemberRepositoryInterface
|
||||||
|
|
||||||
public function create($member);
|
public function create($member);
|
||||||
|
|
||||||
public function update($id);
|
public function update($member);
|
||||||
|
|
||||||
public function auth($request);
|
public function auth($request);
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ use App\Services\Data\PaginateService;
|
||||||
use App\Services\Data\ThemeService;
|
use App\Services\Data\ThemeService;
|
||||||
use App\Services\Data\SortingService;
|
use App\Services\Data\SortingService;
|
||||||
//Upkeep Services
|
//Upkeep Services
|
||||||
use App\Services\UpKeep\MaintenanceService;
|
use App\Services\Upkeep\MaintenanceService;
|
||||||
use App\Services\UpKeep\InitService;
|
use App\Services\Upkeep\InitService;
|
||||||
|
|
||||||
class FipamoServiceProvider extends ServiceProvider
|
class FipamoServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,17 +2,22 @@
|
||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Services\Assets\DocService;
|
||||||
use App\Interfaces\MemberRepositoryInterface;
|
use App\Interfaces\MemberRepositoryInterface;
|
||||||
use ReallySimpleJWT\Token;
|
use ReallySimpleJWT\Token;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
use function _\find;
|
use function _\find;
|
||||||
|
use function _\findIndex;
|
||||||
|
|
||||||
class MemberRepository implements MemberRepositoryInterface
|
class MemberRepository implements MemberRepositoryInterface
|
||||||
{
|
{
|
||||||
protected $folks;
|
protected $folks;
|
||||||
|
protected $docs;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(DocService $docService)
|
||||||
{
|
{
|
||||||
|
$this->docs = $docService;
|
||||||
if (file_exists(env('FOLKS_PATH'))) {
|
if (file_exists(env('FOLKS_PATH'))) {
|
||||||
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,9 +52,17 @@ class MemberRepository implements MemberRepositoryInterface
|
||||||
//make new member
|
//make new member
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id)
|
public function update($member)
|
||||||
{
|
{
|
||||||
//update member data
|
//TODO: need to add member avatar updating
|
||||||
|
$index = findIndex($this->folks, ['id' => $member->id]);
|
||||||
|
$this->folks[$index]['handle'] = $member->handle;
|
||||||
|
$this->folks[$index]['email'] = $member->email;
|
||||||
|
$this->folks[$index]['updated'] = Carbon::now();
|
||||||
|
//save new folks file
|
||||||
|
$this->docs::writeSettings($this->folks, env('FOLKS_PATH'));
|
||||||
|
//update session
|
||||||
|
session()->put('member', $this->folks[$index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth($request)
|
public function auth($request)
|
||||||
|
@ -60,6 +73,7 @@ class MemberRepository implements MemberRepositoryInterface
|
||||||
if ($found) {
|
if ($found) {
|
||||||
if (password_verify($request->password, $found['password'])) {
|
if (password_verify($request->password, $found['password'])) {
|
||||||
$member = [
|
$member = [
|
||||||
|
'id' => $found['id'],
|
||||||
'handle' => $found['handle'],
|
'handle' => $found['handle'],
|
||||||
'email' => $found['email'],
|
'email' => $found['email'],
|
||||||
'role' => $found['role'],
|
'role' => $found['role'],
|
||||||
|
|
|
@ -21,6 +21,8 @@ class SettingsService
|
||||||
} else {
|
} else {
|
||||||
$this->tags = [];
|
$this->tags = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->docs = $docService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadSettings()
|
protected function loadSettings()
|
||||||
|
@ -110,7 +112,6 @@ class SettingsService
|
||||||
|
|
||||||
public function sync($data)
|
public function sync($data)
|
||||||
{
|
{
|
||||||
//dd($data->global->renderOnSave);
|
|
||||||
$settings = $this->getSettings();
|
$settings = $this->getSettings();
|
||||||
$settings['global']['base_url'] = $data->global->base_url;
|
$settings['global']['base_url'] = $data->global->base_url;
|
||||||
$settings['global']['title'] = $data->global->title;
|
$settings['global']['title'] = $data->global->title;
|
||||||
|
@ -129,7 +130,7 @@ class SettingsService
|
||||||
$settings['email']['smtp'] = $data->email->smtp;
|
$settings['email']['smtp'] = $data->email->smtp;
|
||||||
$settings['email']['mailgun'] = $data->email->mailgun;
|
$settings['email']['mailgun'] = $data->email->mailgun;
|
||||||
|
|
||||||
return $this->docs->writeSettings($settings);
|
return $this->docs::writeSettings($settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function navSync($data)
|
public function navSync($data)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services\Upkeep;
|
||||||
|
|
||||||
|
use App\Services\Data\SettingsService;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class MaintenanceService
|
class MaintenanceService
|
||||||
|
|
|
@ -12,6 +12,7 @@ export default class SettingsActions {
|
||||||
let url = document.getElementById('settings-url').value;
|
let url = document.getElementById('settings-url').value;
|
||||||
let title = document.getElementById('settings-title').value;
|
let title = document.getElementById('settings-title').value;
|
||||||
let desc = document.getElementById('settings-desc').value;
|
let desc = document.getElementById('settings-desc').value;
|
||||||
|
let memberID = document.getElementById('member-id').value;
|
||||||
//let privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
|
//let privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
|
||||||
let render = document.getElementById('render-toggle').getAttribute('data-render');
|
let render = document.getElementById('render-toggle').getAttribute('data-render');
|
||||||
let background = document
|
let background = document
|
||||||
|
@ -55,7 +56,11 @@ export default class SettingsActions {
|
||||||
externalAPI: apiStatus,
|
externalAPI: apiStatus,
|
||||||
dynamicRender: dynamicRenderStatus
|
dynamicRender: dynamicRenderStatus
|
||||||
},
|
},
|
||||||
member: { handle: handle, email: email },
|
member: {
|
||||||
|
handle: handle,
|
||||||
|
email: email,
|
||||||
|
id: memberID
|
||||||
|
},
|
||||||
email: {
|
email: {
|
||||||
active: mailActive,
|
active: mailActive,
|
||||||
smtp: {
|
smtp: {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<article class="settings">
|
<article class="settings">
|
||||||
<section class="member-settings">
|
<section class="member-settings">
|
||||||
<div class="member-avatar">
|
<div class="member-avatar">
|
||||||
<div class="avatar" style="background: url({{ $member['avatar'] }} ) no-repeat center center / cover"></div>
|
<div class="avatar" style="background: url({{ $member['avi'] }} ) no-repeat center center / cover"></div>
|
||||||
<input id="avatar-upload" type="file" name="avatar-upload"/>
|
<input id="avatar-upload" type="file" name="avatar-upload"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="site-background">
|
<div class="site-background">
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
<div>
|
<div>
|
||||||
<input type='text' name='handle' id='settings-handle' placeholder='handle' value="{{ $member['handle'] }}" autofocus/>
|
<input type='text' name='handle' id='settings-handle' placeholder='handle' value="{{ $member['handle'] }}" autofocus/>
|
||||||
<input type='text' name='email' id='settings-email' placeholder='email' value="{{ $member['email'] }}" autofocus/>
|
<input type='text' name='email' id='settings-email' placeholder='email' value="{{ $member['email'] }}" autofocus/>
|
||||||
|
<input type='hidden' name='member-id' id='member-id' value="{{ $member['id'] }}"/>
|
||||||
<input type='text' name='base-url' id='settings-url' placeholder='url' value="{{ $baseUrl }}" autofocus/>
|
<input type='text' name='base-url' id='settings-url' placeholder='url' value="{{ $baseUrl }}" autofocus/>
|
||||||
<input type='text' name='base-title' id='settings-title' placeholder='site title' value="{{ $siteTitle }}" autofocus/>
|
<input type='text' name='base-title' id='settings-title' placeholder='site title' value="{{ $siteTitle }}" autofocus/>
|
||||||
<textarea id="settings-desc" type='text' name='settings_desc' class='settings-dec' placeholder='description stuff' , autofocus>{{ $desc }}</textarea>
|
<textarea id="settings-desc" type='text' name='settings_desc' class='settings-dec' placeholder='description stuff' , autofocus>{{ $desc }}</textarea>
|
||||||
|
|
Loading…
Reference in a new issue