Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-SunbirdEd-portal-old
Commits
9b4d0c56
Unverified
Commit
9b4d0c56
authored
5 years ago
by
Rajeev
Committed by
GitHub
5 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #2616 from deveshMantra/autoMerge5
Issue #SB-13773 fix:redirection fix for auto merge of user
parents
462cbd49
961fed91
master
Dark_theme
SB-25589
SB-28090
aws_fileRead
contributions
dependabot/npm_and_yarn/src/app/client/decode-uri-component-0.2.2
dependabot/npm_and_yarn/src/app/decode-uri-component-0.2.2
dependabot/npm_and_yarn/src/app/express-4.17.3
dependabot/npm_and_yarn/src/app/jsonwebtoken-9.0.0
dependabot/npm_and_yarn/src/desktop/OpenRAP/decode-uri-component-0.2.2
dependabot/npm_and_yarn/src/desktop/OpenRAP/express-4.17.3
dependabot/npm_and_yarn/src/desktop/OpenRAP/jsonwebtoken-9.0.0
dependabot/npm_and_yarn/src/desktop/OpenRAP/qs-6.5.3
dependabot/npm_and_yarn/src/desktop/decode-uri-component-0.2.2
dependabot/npm_and_yarn/src/desktop/express-4.17.3
dependabot/npm_and_yarn/src/desktop/jsonwebtoken-9.0.0
dependabot/npm_and_yarn/src/desktop/qs-6.10.3
desktop-common-consumption
filters_5.1.1
gcp
gcp_test
keshavprasadms-patch-1
keshavprasadms-patch-2
release-2.10.0
release-2.10.1
release-2.10.2
release-2.10.3
release-2.4.0
release-2.4.1
release-2.4.2
release-2.5.0
release-2.5.1
release-2.6.0
release-2.6.0-loadtest
release-2.6.5
release-2.6.6
release-2.7.0
release-2.8.0
release-2.8.1
release-2.8.10
release-2.8.11
release-2.8.12
release-2.8.2
release-2.8.3
release-2.8.4
release-2.8.5
release-2.8.6
release-2.8.7
release-2.8.8
release-2.8.9
release-2.9.0
release-3.0
release-3.0-merge
release-3.0.0
release-3.0.1
release-3.0.2
release-3.0.3
release-3.0.4
release-3.0.4-sso
release-3.1.0
release-3.1.1
release-3.1.2
release-3.2.0
release-3.2.1
release-3.2.10
release-3.2.11
release-3.2.12
release-3.2.13
release-3.2.14
release-3.2.2
release-3.2.3
release-3.2.4
release-3.3.0
release-3.3.0-telemetry-fix
release-3.3.1
release-3.3.2
release-3.4.0
release-3.4.1
release-3.4.2
release-3.4.3
release-3.4.4
release-3.4.5
release-3.4.6
release-3.4.7
release-3.5.0
release-3.5.1
release-3.5.2
release-3.5.3
release-3.6.0
release-3.6.1
release-3.6.5
release-3.6.6
release-3.7.0
release-3.7.1
release-3.7.2
release-3.8.0
release-3.8.1
release-3.8.2
release-3.8.3
release-3.9.0
release-3.9.1
release-3.9.2
release-3.9.3
release-4.0.0
release-4.0.1
release-4.0.2
release-4.1
release-4.1.0
release-4.1.1
release-4.10.0
release-4.10.0.1
release-4.10.1
release-4.10.2
release-4.10.2.1
release-4.10.2.2
release-4.10.3
release-4.2.0
release-4.2.1
release-4.3.0
release-4.3.1
release-4.4.0
release-4.4.1
release-4.5.0
release-4.5.1
release-4.5.2
release-4.6.0
release-4.7.0
release-4.7.1
release-4.8.0
release-4.8.5
release-4.9.0
release-4.9.1
release-5.0.0
release-5.0.0.1
release-5.0.0.2
release-5.0.0.3
release-5.0.1
release-5.0.2
release-5.1.0
release-5.1.1
release-sonarcloud
revert-3718-copypi
revert-3842-release-2.8.7
revert-3890-release-2.8.9
revert-4427-player-cache-issue
revert-4537-SB-19763
revert-5244-sh-809
revert-5260-SB-table-3.3.0
revert-8284-release-5.0.0
sharathkashyap-patch-1
Tags unavailable
No related merge requests found
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.html
+20
-0
...-in/sso/components/auth-failed/auth-failed.component.html
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.scss
+0
-0
...-in/sso/components/auth-failed/auth-failed.component.scss
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.spec.ts
+39
-0
.../sso/components/auth-failed/auth-failed.component.spec.ts
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.ts
+29
-0
...gn-in/sso/components/auth-failed/auth-failed.component.ts
src/app/client/src/app/modules/public/module/sign-in/sso/components/index.ts
+1
-0
...app/modules/public/module/sign-in/sso/components/index.ts
src/app/client/src/app/modules/public/module/sign-in/sso/sso-routing.module.ts
+4
-1
...p/modules/public/module/sign-in/sso/sso-routing.module.ts
src/app/client/src/app/modules/public/module/sign-in/sso/sso.module.ts
+3
-3
...t/src/app/modules/public/module/sign-in/sso/sso.module.ts
src/app/routes/ssoRoutes.js
+9
-5
src/app/routes/ssoRoutes.js
with
105 additions
and
9 deletions
+105
-9
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.html
0 → 100644
+
20
−
0
View file @
9b4d0c56
<sui-modal
[isClosable]=
"false"
[size]=
"'fullscreen'"
#modal
[mustScroll]=
"true"
[transitionDuration]=
"0"
class=
"fullpage"
(dismissed)=
"modal.deny()"
>
<div
class=
"sb-certificatePage p-16"
>
<div
class=
"sb-certificatePage-header"
>
<img
src=
"assets/images/DIKSHA.svg"
class=
"sb-certificatePage-logo"
alt=
"DIKSHA Logo"
/>
</div>
<div
class=
"sb-merged-account-content text-center"
>
<h3
class=
"sb-merged-account-body-header my-24 font-weight-bold"
>
{{resourceService.frmelmnts?.lbl?.mergeAccount}}
</h3>
<p
class=
"py-8 m-0"
>
Could not merge accounts because the password entered is incorrect.
Click OK to create a new DIKSHA account
</p>
</div>
<div
class=
"d-flex mt-40"
>
<button
class=
"sb-btn sb-btn-outline-secondary sb-btn-normal width-100 mr-8 mb-auto"
(click)=
"createNewUser()"
>
{{resourceService.frmelmnts?.btn?.ok}}
</button>
</div>
</div>
</sui-modal>
This diff is collapsed.
Click to expand it.
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.scss
0 → 100644
+
0
−
0
View file @
9b4d0c56
This diff is collapsed.
Click to expand it.
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.spec.ts
0 → 100644
+
39
−
0
View file @
9b4d0c56
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
SuiModule
}
from
'
ng2-semantic-ui
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
of
as
observableOf
}
from
'
rxjs
'
;
import
{
ResourceService
}
from
'
@sunbird/shared
'
;
import
{
AuthFailedComponent
}
from
'
./auth-failed.component
'
;
describe
(
'
AuthFailedComponent
'
,
()
=>
{
let
component
:
AuthFailedComponent
;
let
fixture
:
ComponentFixture
<
AuthFailedComponent
>
;
const
fakeActivatedRoute
=
{
'
queryParams
'
:
observableOf
({
userId
:
'
mock user ID
'
,
identifier
:
'
email
'
,
identifierValue
:
'
as
'
}),
};
const
resourceBundle
=
{
languageSelected
$
:
observableOf
({})
};
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[
SuiModule
],
declarations
:
[
AuthFailedComponent
],
providers
:
[{
provide
:
ActivatedRoute
,
useValue
:
fakeActivatedRoute
},
{
provide
:
ResourceService
,
useValue
:
resourceBundle
}]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
AuthFailedComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
This diff is collapsed.
Click to expand it.
src/app/client/src/app/modules/public/module/sign-in/sso/components/auth-failed/auth-failed.component.ts
0 → 100644
+
29
−
0
View file @
9b4d0c56
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
ResourceService
}
from
'
@sunbird/shared
'
;
import
{
ActivatedRoute
}
from
'
@angular/router
'
;
@
Component
({
selector
:
'
app-auth-failed
'
,
templateUrl
:
'
./auth-failed.component.html
'
,
styleUrls
:
[
'
./auth-failed.component.scss
'
]
})
export
class
AuthFailedComponent
implements
OnInit
{
constructor
(
public
activatedRoute
:
ActivatedRoute
,
public
resourceService
:
ResourceService
)
{
}
queryParam
:
any
;
ngOnInit
()
{
this
.
activatedRoute
.
queryParams
.
subscribe
((
queryParams
)
=>
{
this
.
queryParam
=
{...
queryParams
};
});
}
createNewUser
()
{
const
queryParams
=
'
&identifier=
'
+
this
.
queryParam
.
identifierType
+
'
&identifierValue=
'
+
this
.
queryParam
.
identifierValue
+
'
&freeUser=true
'
;
window
.
location
.
href
=
'
v1/sso/create/user?userId=
'
+
this
.
queryParam
.
userId
+
queryParams
;
}
}
This diff is collapsed.
Click to expand it.
src/app/client/src/app/modules/public/module/sign-in/sso/components/index.ts
+
1
−
0
View file @
9b4d0c56
export
*
from
'
./select-org/select-org.component
'
;
export
*
from
'
./update-contact/update-contact.component
'
;
export
*
from
'
./auth-failed/auth-failed.component
'
;
This diff is collapsed.
Click to expand it.
src/app/client/src/app/modules/public/module/sign-in/sso/sso-routing.module.ts
+
4
−
1
View file @
9b4d0c56
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
Routes
,
RouterModule
}
from
'
@angular/router
'
;
import
{
SelectOrgComponent
,
UpdateContactComponent
}
from
'
./components
'
;
import
{
AuthFailedComponent
,
SelectOrgComponent
,
UpdateContactComponent
}
from
'
./components
'
;
import
{
UUID
}
from
'
angular2-uuid
'
;
const
uuid
=
UUID
.
UUID
();
const
telemetryEnv
=
'
sso-sign-in
'
;
...
...
@@ -22,6 +22,9 @@ const routes: Routes = [
env
:
telemetryEnv
,
pageid
:
'
update-contact
'
,
uri
:
'
/update-contact
'
,
type
:
'
view
'
,
mode
:
'
self
'
,
uuid
:
uuid
}
}
},
{
path
:
'
auth
'
,
component
:
AuthFailedComponent
}
];
...
...
This diff is collapsed.
Click to expand it.
src/app/client/src/app/modules/public/module/sign-in/sso/sso.module.ts
+
3
−
3
View file @
9b4d0c56
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
CommonModule
}
from
'
@angular/common
'
;
import
{
SsoRoutingModule
}
from
'
./sso-routing.module
'
;
import
{
SelectOrgComponent
,
UpdateContactComponent
}
from
'
./components
'
;
import
{
TelemetryModule
}
from
'
@sunbird/telemetry
'
;
import
{
SelectOrgComponent
,
UpdateContactComponent
,
AuthFailedComponent
}
from
'
./components
'
;
import
{
TelemetryModule
}
from
'
@sunbird/telemetry
'
;
import
{
SharedFeatureModule
}
from
'
@sunbird/shared-feature
'
;
import
{
SuiModule
}
from
'
ng2-semantic-ui/dist
'
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
'
@angular/forms
'
;
...
...
@@ -19,6 +19,6 @@ import { SharedModule } from '@sunbird/shared';
ReactiveFormsModule
,
SharedModule
],
declarations
:
[
SelectOrgComponent
,
UpdateContactComponent
]
declarations
:
[
SelectOrgComponent
,
UpdateContactComponent
,
AuthFailedComponent
]
})
export
class
SsoModule
{
}
This diff is collapsed.
Click to expand it.
src/app/routes/ssoRoutes.js
+
9
−
5
View file @
9b4d0c56
...
...
@@ -315,7 +315,7 @@ module.exports = (app) => {
req
.
session
.
migrateAccountInfo
.
encryptedData
=
encrypt
(
JSON
.
stringify
(
dataToEncrypt
));
const
payload
=
JSON
.
stringify
(
req
.
session
.
migrateAccountInfo
.
encryptedData
);
url
=
`
${
envHelper
.
PORTAL_AUTH_SERVER_URL
}
/realms/
${
envHelper
.
PORTAL_REALM
}
/protocol/openid-connect/auth`
;
query
=
`?client_id=portal&state=3c9a2d1b-ede9-4e6d-a496-068a490172ee&identifierValue=
${
req
.
query
.
identifierValue
}
&redirect_uri=https://
${
req
.
get
(
'
host
'
)}
/migrate/account/login/callback&payload=
${
payload
}
&scope=openid&response_type=code&automerge=1&version=3&goBackUrl=https://
${
req
.
get
(
'
host
'
)}
${
req
.
query
.
redirectUri
}
`
;
query
=
`?client_id=portal&state=3c9a2d1b-ede9-4e6d-a496-068a490172ee&identifierValue=
${
req
.
query
.
identifierValue
}
&redirect_uri=https://
${
req
.
get
(
'
host
'
)}
/migrate/account/login/callback&payload=
${
payload
}
&scope=openid&response_type=code&automerge=1&version=3&goBackUrl=https://
${
req
.
get
(
'
host
'
)}
/sign-in/sso/select-org
`
;
console
.
log
(
'
url for migration
'
,
url
+
query
);
}
catch
(
error
)
{
response
=
{
error
:
getErrorMessage
(
error
,
errType
)};
...
...
@@ -343,6 +343,7 @@ module.exports = (app) => {
return
false
;
}
if
(
req
.
session
.
migrateAccountInfo
.
client_id
===
'
android
'
)
{
console
.
log
(
'
mobile login success
'
);
const
query
=
'
?payload=
'
+
req
.
session
.
migrateAccountInfo
.
encryptedData
+
'
&code=
'
+
req
.
query
.
code
+
'
&automerge=1
'
;
res
.
redirect
(
'
/account/migrate/login
'
+
query
);
}
else
{
...
...
@@ -352,7 +353,7 @@ module.exports = (app) => {
req
.
session
.
nonStateUserToken
=
nonStateUserToken
;
}
else
{
nonStateUserToken
=
await
generateAuthToken
(
req
.
query
.
code
,
`https://
${
req
.
get
(
'
host
'
)}
/migrate/account/login/callback`
).
catch
(
err
=>
{
console
.
log
(
'
error in verifyAuthToken
'
,
err
.
error
);
console
.
log
(
'
error in verifyAuthToken
'
,
err
);
console
.
log
(
'
error details
'
,
err
.
statusCode
,
err
.
message
)
});
const
userToken
=
parseJson
(
nonStateUserToken
);
...
...
@@ -376,13 +377,16 @@ module.exports = (app) => {
const
decryptedData
=
decrypt
(
req
.
session
.
migrateAccountInfo
.
encryptedData
);
stateUserData
=
parseJson
(
decryptedData
);
errType
=
'
VERIFY_SIGNATURE
'
;
console
.
log
(
'
validating state token
'
,
decryptedData
);
console
.
log
(
'
validating state token
'
,
JSON
.
stringify
(
decryptedData
)
)
;
await
verifySignature
(
stateUserData
.
stateToken
);
errType
=
'
JWT_DECODE
'
;
stateJwtPayload
=
jwt
.
decode
(
stateUserData
.
stateToken
);
errType
=
'
VERIFY_TOKEN
'
;
verifyToken
(
stateJwtPayload
);
const
nonStateUserData
=
jwt
.
decode
(
req
.
session
.
nonStateUserToken
);
errType
=
'
ERROR_VERIFYING_IDENTITY
'
;
const
isMigrationAllowed
=
verifyIdentifier
(
stateUserData
.
identifierValue
,
nonStateUserData
[
stateUserData
.
identifier
],
stateUserData
.
identifier
);
console
.
log
(
'
ismigration allowed
'
,
isMigrationAllowed
);
if
(
isMigrationAllowed
)
{
errType
=
'
MIGRATE_USER
'
;
req
.
query
.
userId
=
getUserIdFromToken
(
req
.
session
.
nonStateUserToken
);
...
...
@@ -399,13 +403,13 @@ module.exports = (app) => {
// await updateRoles(req, req.query.userId, stateJwtPayload).catch(handleProfileUpdateError);
}
req
.
session
.
userDetails
=
userDetails
;
redirectUrl
=
'
/accountMerge?status=success&redirect_uri=/resources
'
;
redirectUrl
=
'
/accountMerge?status=success&
merge_type=auto&
redirect_uri=/resources
'
;
}
else
{
errType
=
'
UNAUTHORIZED
'
;
throw
'
USER_DETAILS_DID_NOT_MATCH
'
;
}
}
catch
(
error
)
{
redirectUrl
=
'
/accountMerge?status=error&redirect_uri=/resources
'
;
redirectUrl
=
'
/accountMerge?status=error&
merge_type=auto&
redirect_uri=/resources
'
;
logger
.
error
({
msg
:
'
sso session create v2 api failed
'
,
"
error
"
:
JSON
.
stringify
(
error
),
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets