Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
221
Issues
221
List
Boards
Labels
Service Desk
Milestones
Merge Requests
35
Merge Requests
35
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
4afce8302e08d4acd60ee47a31f02e07b3ea7255...01c9ba9fe661774118d935288bd972ec5bf414db
Source
01c9ba9fe661774118d935288bd972ec5bf414db
Select Git revision
...
Target
4afce8302e08d4acd60ee47a31f02e07b3ea7255
Select Git revision
Compare
Commits (3)
(chore): Disable self-enable on Pro
· b2141b49
Emiliano Balbuena
authored
1 day ago
Closes
#833
b2141b49
(chore): Allow admins to toggle Pro
· 8231b3bf
Emiliano Balbuena
authored
1 day ago
8231b3bf
(cs): Code lint
· 01c9ba9f
Emiliano Balbuena
authored
1 day ago
01c9ba9f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
36 deletions
+155
-36
pro.php
Controllers/api/v2/admin/pro.php
+117
-0
pro.php
Controllers/api/v2/pro.php
+22
-17
Security.php
Core/Pro/Domain/Security.php
+3
-3
DomainSpec.php
Spec/Core/Pro/DomainSpec.php
+7
-10
SettingsSpec.php
Spec/Core/Pro/SettingsSpec.php
+6
-6
No files found.
Controllers/api/v2/admin/pro.php
0 → 100644
View file @
01c9ba9f
<?php
/**
* pro
*
* @author edgebal
*/
namespace
Minds\Controllers\api\v2\admin
;
use
Minds\Api\Factory
;
use
Minds\Core\Pro\Manager
;
use
Minds\Entities\User
as
UserEntity
;
use
Minds\Interfaces
;
use
Minds\Core\Di\Di
;
class
pro
implements
Interfaces\Api
,
Interfaces\ApiAdminPam
{
/**
* Equivalent to HTTP GET method
* @param array $pages
* @return mixed|null
*/
public
function
get
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* Equivalent to HTTP POST method
* @param array $pages
* @return mixed|null
*/
public
function
post
(
$pages
)
{
return
Factory
::
response
([]);
}
/**
* Equivalent to HTTP PUT method
* @param array $pages
* @return mixed|null
*/
public
function
put
(
$pages
)
{
if
(
!
(
$pages
[
0
]
??
null
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Emtpy target'
,
]);
}
$target
=
new
UserEntity
(
$pages
[
0
]);
if
(
!
$target
||
!
$target
->
guid
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Invalid target'
,
]);
}
/** @var Manager $manager */
$manager
=
Di
::
_
()
->
get
(
'Pro\Manager'
);
$manager
->
setUser
(
$target
);
$success
=
$manager
->
enable
(
time
()
+
(
365
*
86400
));
if
(
!
$success
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Error disabling Pro'
,
]);
}
return
Factory
::
response
([]);
}
/**
* Equivalent to HTTP DELETE method
* @param array $pages
* @return mixed|null
*/
public
function
delete
(
$pages
)
{
if
(
!
(
$pages
[
0
]
??
null
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Emtpy target'
,
]);
}
$target
=
new
UserEntity
(
$pages
[
0
]);
if
(
!
$target
||
!
$target
->
guid
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Invalid target'
,
]);
}
/** @var Manager $manager */
$manager
=
Di
::
_
()
->
get
(
'Pro\Manager'
);
$manager
->
setUser
(
$target
);
$success
=
$manager
->
disable
();
if
(
!
$success
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Error disabling Pro'
,
]);
}
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/pro.php
View file @
01c9ba9f
...
...
@@ -40,25 +40,30 @@ class pro implements Interfaces\Api
*/
public
function
post
(
$pages
)
{
/** @var Manager $manager */
$manager
=
Di
::
_
()
->
get
(
'Pro\Manager'
);
$manager
->
setUser
(
Session
::
getLoggedinUser
());
// TODO: Send and process payment data
$success
=
$manager
->
enable
(
time
()
+
(
365
*
86400
));
if
(
!
$success
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Error activating Pro'
,
]);
}
return
Factory
::
response
([
'
isActive'
=>
$manager
->
isActive
()
,
'
settings'
=>
$manager
->
get
()
,
'
status'
=>
'error'
,
'
message'
=>
'Minds Pro is not yet publicly available.'
,
]);
// /** @var Manager $manager */
// $manager = Di::_()->get('Pro\Manager');
// $manager
// ->setUser(Session::getLoggedinUser());
//
// // TODO: Send and process payment data
// $success = $manager->enable(time() + (365 * 86400));
//
// if (!$success) {
// return Factory::response([
// 'status' => 'error',
// 'message' => 'Error activating Pro',
// ]);
// }
//
// return Factory::response([
// 'isActive' => $manager->isActive(),
// 'settings' => $manager->get(),
// ]);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Core/Pro/Domain/Security.php
View file @
01c9ba9f
...
...
@@ -40,8 +40,7 @@ class Security
$cookie
=
null
,
$jwt
=
null
,
$config
=
null
)
{
)
{
$this
->
cookie
=
$cookie
?:
new
Cookie
();
$this
->
jwt
=
$jwt
?:
new
Jwt
();
$this
->
config
=
$config
?:
Di
::
_
()
->
get
(
'Config'
);
...
...
@@ -114,7 +113,8 @@ class Security
->
setPath
(
'/'
)
->
setHttpOnly
(
false
)
->
create
();
}
catch
(
Exception
$e
)
{
}
}
catch
(
Exception
$e
)
{
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Pro/DomainSpec.php
View file @
01c9ba9f
...
...
@@ -19,27 +19,25 @@ class DomainSpec extends ObjectBehavior
/** @var Repository */
protected
$repository
;
function
let
(
public
function
let
(
Config
$config
,
Repository
$repository
)
{
)
{
$this
->
config
=
$config
;
$this
->
repository
=
$repository
;
$this
->
beConstructedWith
(
$config
,
$repository
);
}
function
it_is_initializable
()
public
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
Domain
::
class
);
}
function
it_should_lookup_for_a_domain
(
public
function
it_should_lookup_for_a_domain
(
Response
$repositoryResponse
,
Settings
$settings
)
{
)
{
$this
->
config
->
get
(
'root_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'minds.com'
]);
...
...
@@ -59,11 +57,10 @@ class DomainSpec extends ObjectBehavior
->
shouldReturn
(
$settings
);
}
function
it_should_get_an_icon
(
public
function
it_should_get_an_icon
(
Settings
$settings
,
User
$user
)
{
)
{
$user
->
getIconURL
(
'large'
)
->
shouldBeCalled
()
->
willReturn
(
'/1000/large'
);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Pro/SettingsSpec.php
View file @
01c9ba9f
...
...
@@ -8,12 +8,12 @@ use Prophecy\Argument;
class
SettingsSpec
extends
ObjectBehavior
{
function
it_is_initializable
()
public
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
Settings
::
class
);
}
function
it_should_get_one_line_headline_from_single_line_value
()
public
function
it_should_get_one_line_headline_from_single_line_value
()
{
$this
->
setHeadline
(
'This is a headline'
);
...
...
@@ -22,7 +22,7 @@ class SettingsSpec extends ObjectBehavior
->
shouldReturn
(
'This is a headline'
);
}
function
it_should_get_one_line_headline_from_multi_line_value
()
public
function
it_should_get_one_line_headline_from_multi_line_value
()
{
$this
->
setHeadline
(
"This is a headline.
\n
Other line"
);
...
...
@@ -31,21 +31,21 @@ class SettingsSpec extends ObjectBehavior
->
shouldReturn
(
'This is a headline. Other line'
);
}
function
it_should_export
()
public
function
it_should_export
()
{
$this
->
export
()
->
shouldBeArray
();
}
function
it_should_build_styles
()
public
function
it_should_build_styles
()
{
$this
->
buildStyles
()
->
shouldBeArray
();
}
function
it_should_calc_tile_ratio_percentage
()
public
function
it_should_calc_tile_ratio_percentage
()
{
$this
->
setTileRatio
(
'1:1'
);
...
...
This diff is collapsed.
Click to expand it.