Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
804
Merge Requests
54
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
3fb537fb
Commit
3fb537fb
authored
20 minutes ago
by
Emiliano Balbuena
Browse files
Options
Download
(feat): Reverse SSO
parent
22dc11d2
goal/pro-sso
1 merge request
!656
WIP: SSO for Pro sites
Pipeline
#96255662
running with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
10 deletions
+52
-10
src/app/common/services/sso.service.ts
View file @
3fb537fb
...
...
@@ -11,7 +11,17 @@ export class SsoService {
protected
site
:
SiteService
,
protected
client
:
Client
,
protected
session
:
Session
)
{}
)
{
this
.
listen
();
}
listen
()
{
this
.
session
.
isLoggedIn
((
is
:
boolean
)
=>
{
if
(
is
)
{
this
.
auth
();
}
});
}
isRequired
():
boolean
{
return
this
.
site
.
isProDomain
;
...
...
@@ -32,8 +42,25 @@ export class SsoService {
}
);
window
.
Minds
.
user
=
authorization
.
user
;
this
.
session
.
login
(
window
.
Minds
.
user
);
this
.
session
.
inject
(
window
.
Minds
.
user
);
}
}
catch
(
e
)
{
console
.
error
(
e
);
}
}
async
auth
()
{
try
{
const
connect
:
any
=
await
this
.
client
.
post
(
'
api/v2/sso/connect
'
);
if
(
connect
&&
connect
.
token
&&
connect
.
status
===
'
success
'
)
{
// TODO: Use headers
await
this
.
client
.
postRaw
(
`
${
this
.
minds
.
site_url
}
api/v2/sso/authorize`
,
{
token
:
connect
.
token
,
}
);
}
}
catch
(
e
)
{
console
.
error
(
e
);
...
...
This diff is collapsed.
src/app/services/providers.ts
View file @
3fb537fb
...
...
@@ -112,6 +112,7 @@ export const MINDS_PROVIDERS: any[] = [
{
provide
:
Session
,
useFactory
:
Session
.
_
,
deps
:
[
SiteService
],
},
{
provide
:
ThirdPartyNetworksService
,
...
...
This diff is collapsed.
src/app/services/session.ts
View file @
3fb537fb
...
...
@@ -56,16 +56,30 @@ export class Session {
return
false
;
}
/**
* Emit login event
*/
login
(
user
:
any
=
null
)
{
//clear stale local storage
inject
(
user
:
any
=
null
)
{
// Clear stale localStorage
window
.
localStorage
.
clear
();
// Emit new user info
this
.
userEmitter
.
next
(
user
);
window
.
Minds
.
user
=
user
;
if
(
user
.
admin
===
true
)
window
.
Minds
.
Admin
=
true
;
// Set globals
window
.
Minds
.
LoggedIn
=
true
;
window
.
Minds
.
user
=
user
;
if
(
user
.
admin
===
true
)
{
window
.
Minds
.
Admin
=
true
;
}
}
/**
* Inject user and emit login event
*/
login
(
user
:
any
=
null
)
{
this
.
inject
(
user
);
this
.
loggedinEmitter
.
next
(
true
);
}
...
...
This diff is collapsed.
Please
register
or
sign in
to comment