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
213
Issues
213
List
Boards
Labels
Service Desk
Milestones
Merge Requests
34
Merge Requests
34
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
Commits
754c3a2d
Commit
754c3a2d
authored
2 hours ago
by
Marcelo Rivera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): auto-subscribe on login and signup when on pro standalone
parent
bf5c71db
epic/minds-pro
1 merge request
!308
WIP: (feat): Minds Pro
Pipeline
#82522613
failed with stages
in 10 minutes and 22 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
12 deletions
+45
-12
authenticate.php
Controllers/api/v1/authenticate.php
+28
-1
register.php
Controllers/api/v1/register.php
+12
-9
Registered.php
Core/Queue/Runners/Registered.php
+5
-2
No files found.
Controllers/api/v1/authenticate.php
View file @
754c3a2d
...
...
@@ -16,6 +16,8 @@ use Minds\Entities;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Exceptions\TwoFactorRequired
;
use
Minds\Core\Queue
;
use
Minds\Core\Subscriptions
;
class
authenticate
implements
Interfaces\Api
,
Interfaces\ApiIgnorePam
{
...
...
@@ -46,6 +48,9 @@ class authenticate implements Interfaces\Api, Interfaces\ApiIgnorePam
}
$user
=
new
Entities\User
(
strtolower
(
$_POST
[
'username'
]));
$from
=
$_POST
[
'from'
]
??
null
;
/** @var Core\Security\LoginAttempts $attempts */
$attempts
=
Core\Di\Di
::
_
()
->
get
(
'Security\LoginAttempts'
);
...
...
@@ -106,6 +111,28 @@ class authenticate implements Interfaces\Api, Interfaces\ApiIgnorePam
Di
::
_
()
->
get
(
'Features\Manager'
)
->
setCanaryCookie
(
$user
->
isCanary
());
// auto-subscribe to channel
if
(
$from
)
{
$targetChannel
=
new
Entities\User
(
$from
);
$manager
=
(
new
Subscriptions\Manager
())
->
setSubscriber
(
$user
);
if
(
!
$manager
->
isSubscribed
(
$targetChannel
))
{
$manager
->
subscribe
(
$targetChannel
);
}
//TODO: move Core/Subscriptions/Delegates
$event
=
new
Core\Analytics\Metrics\Event
();
$event
->
setType
(
'action'
)
->
setAction
(
'subscribe'
)
->
setProduct
(
'platform'
)
->
setUserGuid
((
string
)
Core\Session
::
getLoggedInUser
()
->
guid
)
->
setUserPhoneNumberHash
(
Core\Session
::
getLoggedInUser
()
->
getPhoneNumberHash
())
->
setEntityGuid
((
string
)
$from
)
->
push
();
}
$response
[
'status'
]
=
'success'
;
$response
[
'user'
]
=
$user
->
export
();
...
...
@@ -119,7 +146,7 @@ class authenticate implements Interfaces\Api, Interfaces\ApiIgnorePam
public
function
delete
(
$pages
)
{
$sessions
=
Di
::
_
()
->
get
(
'Sessions\Manager'
);
if
(
isset
(
$pages
[
0
])
&&
$pages
[
0
]
===
'all'
)
{
$sessions
->
destroy
(
true
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/register.php
View file @
754c3a2d
...
...
@@ -5,14 +5,13 @@
* @version 1
* @author Mark Harding
*/
namespace
Minds\Controllers\api\v1
;
use
Minds\Api\Factory
;
use
Minds\Core
;
use
Minds\Core\Di\Di
;
use
Minds\Entities
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Helpers
;
class
register
implements
Interfaces\Api
,
Interfaces\ApiIgnorePam
{
...
...
@@ -21,7 +20,7 @@ class register implements Interfaces\Api, Interfaces\ApiIgnorePam
*/
public
function
get
(
$pages
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'GET is not supported for this endpoint'
]);
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'GET is not supported for this endpoint'
]);
}
/**
...
...
@@ -37,11 +36,11 @@ class register implements Interfaces\Api, Interfaces\ApiIgnorePam
public
function
post
(
$pages
)
{
if
(
!
isset
(
$_POST
[
'username'
])
||
!
isset
(
$_POST
[
'password'
])
||
!
isset
(
$_POST
[
'username'
])
||
!
isset
(
$_POST
[
'email'
]))
{
return
Factory
::
response
([
'status'
=>
'error'
]);
return
Factory
::
response
([
'status'
=>
'error'
]);
}
if
(
!
$_POST
[
'username'
]
||
!
$_POST
[
'password'
]
||
!
$_POST
[
'username'
]
||
!
$_POST
[
'email'
])
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
"Please fill out all the fields"
]);
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
"Please fill out all the fields"
]);
}
try
{
...
...
@@ -85,6 +84,10 @@ class register implements Interfaces\Api, Interfaces\ApiIgnorePam
'referrer'
=>
isset
(
$_COOKIE
[
'referrer'
])
?
$_COOKIE
[
'referrer'
]
:
''
,
];
if
(
isset
(
$_POST
[
'from'
]))
{
$params
[
'from'
]
=
(
string
)
$_POST
[
'from'
];
}
// TODO: Move full reguster flow to the core
elgg_trigger_plugin_hook
(
'register'
,
'user'
,
$params
,
true
);
Core\Events\Dispatcher
::
trigger
(
'register'
,
'user'
,
$params
);
...
...
@@ -96,11 +99,11 @@ class register implements Interfaces\Api, Interfaces\ApiIgnorePam
$sessions
->
save
();
// Save to db and cookie
$response
=
[
'guid'
=>
$guid
,
'user'
=>
$user
->
export
()
'guid'
=>
$guid
,
'user'
=>
$user
->
export
(),
];
}
catch
(
\Exception
$e
)
{
$response
=
[
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()];
$response
=
[
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()];
}
return
Factory
::
response
(
$response
);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Queue/Runners/Registered.php
View file @
754c3a2d
<?php
namespace
Minds\Core\Queue\Runners
;
use
Minds\Core\Di\Di
;
...
...
@@ -24,11 +23,15 @@ class Registered implements QueueRunner
->
receive
(
function
(
$data
)
use
(
$subscriptions
,
$repository
)
{
$data
=
$data
->
getData
();
$user_guid
=
$data
[
'user_guid'
];
$from
=
$data
[
'from'
];
//subscribe to minds channel
$subscriber
=
new
User
(
$user_guid
);
$subscriber
->
subscribe
(
'100000000000000519'
);
if
(
$from
)
{
$subscriber
->
subscribe
(
$from
);
}
echo
"[registered]: User registered
$user_guid
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment