Skip to content

Commit 988f08e

Browse files
author
Praesidiarius
committed
mass dep fixes
1 parent 5a94fd7 commit 988f08e

File tree

9 files changed

+452
-10
lines changed

9 files changed

+452
-10
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "onePlace User Module",
44
"type": "oneplace-module",
55
"license": "BSD-3-Clause",
6-
"version": "1.0.21",
6+
"version": "1.0.22",
77
"keywords": [
88
"laminas",
99
"mvc",

config/module.config.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@
5353
],
5454
],
5555
'denied' => [
56-
'type' => Literal::class,
56+
'type' => Segment::class,
5757
'options' => [
58-
'route' => '/denied',
58+
'route' => '/denied[/:permission]',
59+
'constraints' => [
60+
'permission' => '[a-zA-Z0-9-_]*',
61+
],
5962
'defaults' => [
6063
'controller' => Controller\AuthController::class,
6164
'action' => 'denied',
@@ -77,7 +80,7 @@
7780
'options' => [
7881
'route' => '/reset-password[/:username[/:token]]',
7982
'constraints' => [
80-
'username' => '[a-zA-Z0-9]*',
83+
'username' => '[a-zA-Z0-9-_]*',
8184
'token' => '[a-zA-Z0-9]+',
8285
],
8386
'defaults' => [

data/structure.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ ALTER TABLE `user_search`
192192
ALTER TABLE `user_search`
193193
MODIFY `Search_ID` int(11) NOT NULL AUTO_INCREMENT;
194194

195+
CREATE TABLE `user_registration` (
196+
`Registration_ID` int(11) NOT NULL,
197+
`user_token` varchar(255) NOT NULL,
198+
`created_date` datetime NOT NULL
199+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
200+
201+
ALTER TABLE `user_registration`
202+
ADD PRIMARY KEY (`Registration_ID`);
203+
204+
ALTER TABLE `user_registration`
205+
MODIFY `Registration_ID` int(11) NOT NULL AUTO_INCREMENT;
206+
195207
--
196208
-- Save
197209
--

src/Controller/ApiController.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,35 @@ private function generateKey()
330330

331331
return $sKey;
332332
}
333+
334+
public function finishsetupAction()
335+
{
336+
$this->layout('layout/json');
337+
338+
$sSystemName = $this->params()->fromRoute('systemkey', '');
339+
340+
$aResponse = ['state' => 'error', 'message' => 'unkown error'];
341+
if($sSystemName != '') {
342+
$oReqTbl = new TableGateway('user_instance_request', CoreController::$oDbAdapter);
343+
344+
$oRequest = $oReqTbl->select(['name' => $sSystemName]);
345+
if(count($oRequest) > 0 ) {
346+
$oRequest = $oRequest->current();
347+
$bHasProtocol = stripos('https://',$oRequest->url);
348+
if($bHasProtocol === false) {
349+
$oRequest->url = 'https://'.$oRequest->url;
350+
}
351+
$sLog = '+++ Starting Installation<br/>+++ Request to License Server<br/>+++ Installing onePlace Modules<br/>+++ Done ! You can now login to <a target="_blank" href="'.$oRequest->url.'">your new onePlace</a><br/>Username: '.$sSystemName.'<br/>Password: <i>Your my.onep.lc Password</i>';
352+
file_put_contents($_SERVER['DOCUMENT_ROOT'].'/data/installer/'.$oRequest->Request_ID.'/status.log',$sLog);
353+
$oReqTbl->delete(['Request_ID' => $oRequest->Request_ID]);
354+
} else {
355+
$aResponse = ['state' => 'error', 'message' => 'request not found'];
356+
}
357+
} else {
358+
$aResponse = ['state' => 'error', 'message' => 'invalid system name'];
359+
}
360+
361+
echo json_encode($aResponse);
362+
return false;
363+
}
333364
}

src/Controller/AuthController.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ public function loginAction()
100100
# Login Successful - redirect to Dashboard
101101
CoreController::$oSession->oUser = $oUser;
102102

103+
# Check if it is first login
104+
$oPermTbl = new TableGateway('user_permission', CoreController::$oDbAdapter);
105+
$aPerms = $oPermTbl->select();
106+
if(count($aPerms) == 0) {
107+
$aBasePerms = CoreController::$aCoreTables['permission']->select([
108+
'needs_globaladmin' => 0
109+
]);
110+
if(count($aBasePerms) > 0) {
111+
foreach($aBasePerms as $oPerm) {
112+
$oPermTbl->insert([
113+
'user_idfs' => $oUser->getID(),
114+
'permission' => $oPerm->permission_key,
115+
'module' => $oPerm->module,
116+
]);
117+
}
118+
}
119+
}
120+
103121
# Add XP for successful login
104122
$oUser->addXP('login');
105123

@@ -138,7 +156,7 @@ public function deniedAction()
138156
# Set Layout based on users theme
139157
$this->setThemeBasedLayout('user');
140158

141-
$sPermission = $this->params()->fromRoute('id', 'Def');
159+
$sPermission = $this->params()->fromRoute('permission', 'Def');
142160

143161
return new ViewModel([
144162
'sPermission' => $sPermission,

src/Model/UserTable.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@ public function saveSingle(User $user)
141141
'lang' => $user->lang,
142142
];
143143

144+
$iCreatorID = (isset(CoreController::$oSession->oUser)) ? CoreController::$oSession->oUser->getID() : 1;
145+
144146
$id = (int) $user->id;
145147

146148
if ($id === 0) {
147149
# add dates
148-
$data['created_by'] = CoreController::$oSession->oUser->getID();
150+
$data['created_by'] = $iCreatorID;
149151
$data['created_date'] = date('Y-m-d H:i:s', time());
150-
$data['modified_by'] = CoreController::$oSession->oUser->getID();
152+
$data['modified_by'] = $iCreatorID;
151153
$data['modified_date'] = date('Y-m-d H:i:s', time());
152154

153155
$this->tableGateway->insert($data);
@@ -165,7 +167,7 @@ public function saveSingle(User $user)
165167

166168
# add modified date
167169
if(isset($oSession->oUser)) {
168-
$data['modified_by'] = CoreController::$oSession->oUser->getID();
170+
$data['modified_by'] = $iCreatorID;
169171
$data['modified_date'] = date('Y-m-d H:i:s', time());
170172
}
171173

src/Module.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Module
3434
*
3535
* @since 1.0.0
3636
*/
37-
const VERSION = '1.0.21';
37+
const VERSION = '1.0.22';
3838

3939
/**
4040
* Load module config file
@@ -120,7 +120,7 @@ function ($e) {
120120
$response->getHeaders()->addHeaderLine(
121121
'Location',
122122
$e->getRouter()->assemble(
123-
['id' => $aRouteInfo['action']],
123+
['permission' => $aRouteInfo['action'].'-'.str_replace(['\\'],['-'],$aRouteInfo['controller'])],
124124
['name' => 'denied']
125125
)
126126
);
@@ -159,6 +159,7 @@ function ($e) {
159159
'login' => [],
160160
'reset-pw' => [],
161161
'forgot-pw' => [],
162+
'register' => [],
162163
];
163164

164165
/**

0 commit comments

Comments
 (0)