Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PERFORMA_REPLICA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Usman
PERFORMA_REPLICA
Commits
e3983e78
Commit
e3983e78
authored
Jul 06, 2020
by
Muhammad Usman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auth module code refactoring
parent
7bbd37e6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
41 deletions
+72
-41
forgot-password.component.ts
...eer-web/auth/forgot-password/forgot-password.component.ts
+8
-9
login.component.ts
...gular/src/app/my-career-web/auth/login/login.component.ts
+10
-13
register.component.ts
...src/app/my-career-web/auth/register/register.component.ts
+10
-12
wrapper.component.ts
...rc/app/my-career-web/layouts/wrapper/wrapper.component.ts
+12
-3
auth.service.ts
...nd/angular/src/app/my-career-web/services/auth.service.ts
+32
-4
No files found.
frontend/angular/src/app/my-career-web/auth/forgot-password/forgot-password.component.ts
View file @
e3983e78
...
@@ -4,8 +4,8 @@ import { takeUntil } from 'rxjs/operators';
...
@@ -4,8 +4,8 @@ import { takeUntil } from 'rxjs/operators';
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
EXTERNAL_LINKS
}
from
'../../config/constants'
;
import
{
EXTERNAL_LINKS
}
from
'../../config/constants'
;
import
{
AuthService
}
from
'../../services/auth.service'
;
import
{
AuthService
}
from
'../../services/auth.service'
;
import
{
HelperService
}
from
'../../services/helper.service'
;
import
{
ToasterService
}
from
'../../services/toaster.service'
;
import
{
ToasterService
}
from
'../../services/toaster.service'
;
import
{
UtilsService
}
from
'../../../oneit/services/utils.service'
;
@
Component
({
@
Component
({
selector
:
'app-forgot-password'
,
selector
:
'app-forgot-password'
,
...
@@ -23,30 +23,29 @@ export class ForgotPasswordComponent extends BaseComponent {
...
@@ -23,30 +23,29 @@ export class ForgotPasswordComponent extends BaseComponent {
@
ViewChild
(
'form'
)
form
:
NgForm
;
@
ViewChild
(
'form'
)
form
:
NgForm
;
constructor
(
constructor
(
private
hs
:
Help
erService
,
private
toasterService
:
Toast
erService
,
private
ts
:
Toaster
Service
,
private
authService
:
Auth
Service
,
private
as
:
Auth
Service
private
utilsService
:
Utils
Service
)
{
)
{
super
();
super
();
}
}
forgot
():
void
{
forgot
():
void
{
if
(
this
.
form
.
invalid
)
{
if
(
this
.
form
.
invalid
)
{
return
this
.
hs
.
validateAllFormFields
(
this
.
form
);
return
this
.
utilsService
.
showAllErrorMessages
(
);
}
}
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
a
s
.
forgot
(
this
.
forgotForm
)
this
.
a
uthService
.
forgot
(
this
.
forgotForm
)
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
subscribe
(
response
=>
{
.
subscribe
(
response
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hs
.
oneItHttpResponse
(
response
);
if
(
response
.
emailSent
)
{
if
(
response
.
emailSent
)
{
this
.
emailSent
=
true
;
this
.
emailSent
=
true
;
this
.
t
s
.
success
(
'Please check your email for instructions.'
);
this
.
t
oasterService
.
success
(
'Please check your email for instructions.'
);
}
}
},
err
=>
{
},
err
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hs
.
handleHttp
Error
(
err
);
this
.
utilsService
.
handle
Error
(
err
);
});
});
}
}
...
...
frontend/angular/src/app/my-career-web/auth/login/login.component.ts
View file @
e3983e78
...
@@ -6,7 +6,6 @@ import { AppService } from '../../../app.service';
...
@@ -6,7 +6,6 @@ import { AppService } from '../../../app.service';
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
EXTERNAL_LINKS
}
from
'../../config/constants'
;
import
{
EXTERNAL_LINKS
}
from
'../../config/constants'
;
import
{
AuthService
}
from
'../../services/auth.service'
;
import
{
AuthService
}
from
'../../services/auth.service'
;
import
{
HelperService
}
from
'../../services/helper.service'
;
import
{
UtilsService
}
from
'../../../oneit/services/utils.service'
;
import
{
UtilsService
}
from
'../../../oneit/services/utils.service'
;
@
Component
({
@
Component
({
...
@@ -26,40 +25,38 @@ export class LoginComponent extends BaseComponent {
...
@@ -26,40 +25,38 @@ export class LoginComponent extends BaseComponent {
@
ViewChild
(
'form'
)
form
:
NgForm
;
@
ViewChild
(
'form'
)
form
:
NgForm
;
constructor
(
constructor
(
private
hs
:
HelperService
,
private
authService
:
AuthService
,
private
as
:
AuthService
,
private
router
:
Router
,
private
r
:
Router
,
private
appService
:
AppService
,
private
aps
:
AppService
,
private
utilsService
:
UtilsService
private
us
:
UtilsService
)
{
)
{
super
();
super
();
}
}
login
():
void
{
login
():
void
{
if
(
this
.
form
.
invalid
)
{
if
(
this
.
form
.
invalid
)
{
return
this
.
u
s
.
showAllErrorMessages
();
return
this
.
u
tilsService
.
showAllErrorMessages
();
}
}
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
a
s
.
login
(
this
.
loginForm
)
this
.
a
uthService
.
login
(
this
.
loginForm
)
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
subscribe
(
response
=>
{
.
subscribe
(
response
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hs
.
oneItHttpResponse
(
response
);
if
(
response
.
status
===
'error'
)
{
if
(
response
.
status
===
'error'
)
{
this
.
loginForm
.
password
=
''
;
this
.
loginForm
.
password
=
''
;
return
;
return
;
}
}
this
.
r
.
navigate
([
'/my-career-web/dashboard'
]);
this
.
r
outer
.
navigate
([
'/my-career-web/dashboard'
]);
},
err
=>
{
},
err
=>
{
this
.
hs
.
handleHttp
Error
(
err
);
this
.
utilsService
.
handle
Error
(
err
);
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
});
});
}
}
socialMediaLogin
(
type
:
'google'
|
'linkedIn'
)
{
socialMediaLogin
(
type
:
'google'
|
'linkedIn'
)
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
ap
s
.
socicalMediaLogin
(
type
)
this
.
ap
pService
.
socicalMediaLogin
(
type
)
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
subscribe
(
data
=>
{
.
subscribe
(
data
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
...
@@ -70,7 +67,7 @@ export class LoginComponent extends BaseComponent {
...
@@ -70,7 +67,7 @@ export class LoginComponent extends BaseComponent {
},
},
err
=>
{
err
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hs
.
handleHttp
Error
(
err
);
this
.
utilsService
.
handle
Error
(
err
);
}
}
)
)
}
}
...
...
frontend/angular/src/app/my-career-web/auth/register/register.component.ts
View file @
e3983e78
...
@@ -5,8 +5,8 @@ import { takeUntil } from 'rxjs/operators';
...
@@ -5,8 +5,8 @@ import { takeUntil } from 'rxjs/operators';
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
EXTERNAL_LINKS
}
from
'../../config/constants'
;
import
{
EXTERNAL_LINKS
}
from
'../../config/constants'
;
import
{
AuthService
}
from
'../../services/auth.service'
;
import
{
AuthService
}
from
'../../services/auth.service'
;
import
{
HelperService
}
from
'../../services/helper.service'
;
import
{
ToasterService
}
from
'../../services/toaster.service'
;
import
{
ToasterService
}
from
'../../services/toaster.service'
;
import
{
UtilsService
}
from
'../../../oneit/services/utils.service'
;
@
Component
({
@
Component
({
selector
:
'app-register'
,
selector
:
'app-register'
,
...
@@ -32,36 +32,34 @@ export class RegisterComponent extends BaseComponent {
...
@@ -32,36 +32,34 @@ export class RegisterComponent extends BaseComponent {
@
ViewChild
(
'form'
)
form
:
NgForm
;
@
ViewChild
(
'form'
)
form
:
NgForm
;
constructor
(
constructor
(
private
hs
:
Helper
Service
,
private
authService
:
Auth
Service
,
private
as
:
Auth
Service
,
private
toasterService
:
Toaster
Service
,
private
ts
:
ToasterService
,
private
router
:
Router
,
private
r
:
Router
private
utilsService
:
UtilsService
)
{
)
{
super
();
super
();
}
}
register
():
void
{
register
():
void
{
if
(
this
.
form
.
invalid
)
{
if
(
this
.
form
.
invalid
)
{
return
this
.
hs
.
validateAllFormFields
(
this
.
form
);
return
this
.
utilsService
.
showAllErrorMessages
(
);
}
}
this
.
registerForm
.
email
=
this
.
registerForm
.
username
;
this
.
registerForm
.
email
=
this
.
registerForm
.
username
;
if
(
!
this
.
registerForm
.
was_referred
)
{
if
(
!
this
.
registerForm
.
was_referred
)
{
delete
this
.
registerForm
.
ReferralCode
;
delete
this
.
registerForm
.
ReferralCode
;
}
}
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
a
s
.
register
(
this
.
registerForm
)
this
.
a
uthService
.
register
(
this
.
registerForm
)
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
subscribe
(
response
=>
{
.
subscribe
(
response
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hs
.
oneItHttpResponse
(
response
);
if
(
response
.
registered
)
{
if
(
response
.
registered
)
{
this
.
t
s
.
success
(
'Registration successful'
);
this
.
t
oasterService
.
success
(
'Registration successful'
);
this
.
r
.
navigate
([
'/my-career-web/dashboard'
]);
this
.
r
outer
.
navigate
([
'/my-career-web/dashboard'
]);
}
}
},
err
=>
{
},
err
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hs
.
handleHttp
Error
(
err
);
this
.
utilsService
.
handle
Error
(
err
);
});
});
}
}
...
...
frontend/angular/src/app/my-career-web/layouts/wrapper/wrapper.component.ts
View file @
e3983e78
...
@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
...
@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
import
{
MsgsService
}
from
'../../../oneit/services/msgs.service'
;
import
{
MsgsService
}
from
'../../../oneit/services/msgs.service'
;
import
{
takeUntil
}
from
'rxjs/operators'
;
import
{
takeUntil
}
from
'rxjs/operators'
;
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
BaseComponent
}
from
'../../base/base.component'
;
import
{
ToasterService
}
from
'../../services/toaster.service'
;
@
Component
({
@
Component
({
selector
:
'app-wrapper'
,
selector
:
'app-wrapper'
,
...
@@ -21,7 +22,8 @@ import { BaseComponent } from '../../base/base.component';
...
@@ -21,7 +22,8 @@ import { BaseComponent } from '../../base/base.component';
export
class
WrapperComponent
extends
BaseComponent
implements
OnInit
{
export
class
WrapperComponent
extends
BaseComponent
implements
OnInit
{
constructor
(
constructor
(
private
msgService
:
MsgsService
private
msgService
:
MsgsService
,
private
toasterService
:
ToasterService
)
{
)
{
super
();
super
();
}
}
...
@@ -29,8 +31,15 @@ export class WrapperComponent extends BaseComponent implements OnInit {
...
@@ -29,8 +31,15 @@ export class WrapperComponent extends BaseComponent implements OnInit {
ngOnInit
()
{
ngOnInit
()
{
this
.
msgService
.
errorMsgsUpdated
this
.
msgService
.
errorMsgsUpdated
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
pipe
(
takeUntil
(
this
.
componentInView
))
.
subscribe
(
error
=>
{
.
subscribe
(
errors
=>
{
// console.log(error);
console
.
log
(
errors
);
if
(
Array
.
isArray
(
errors
))
{
errors
.
forEach
((
err
,
i
)
=>
{
if
(
i
>
0
)
{
this
.
toasterService
.
error
(
err
.
detail
);
}
})
}
});
});
}
}
...
...
frontend/angular/src/app/my-career-web/services/auth.service.ts
View file @
e3983e78
...
@@ -18,25 +18,53 @@ export class AuthService {
...
@@ -18,25 +18,53 @@ export class AuthService {
login
(
formData
):
Observable
<
any
>
{
login
(
formData
):
Observable
<
any
>
{
formData
.
environment
=
this
.
env
;
formData
.
environment
=
this
.
env
;
return
this
.
apiService
.
post
(
'svc/Login'
,
formData
);
return
this
.
apiService
.
post
(
'svc/Login'
,
formData
)
.
map
(
data
=>
{
if
(
this
.
utilsService
.
isSuccessfulResponse
(
data
))
{
return
data
;
}
}
);
}
}
forgot
(
formData
):
Observable
<
any
>
{
forgot
(
formData
):
Observable
<
any
>
{
formData
.
environment
=
this
.
env
;
formData
.
environment
=
this
.
env
;
return
this
.
apiService
.
post
(
'svc/RequestPasswordReset'
,
formData
);
return
this
.
apiService
.
post
(
'svc/RequestPasswordReset'
,
formData
)
.
map
(
data
=>
{
if
(
this
.
utilsService
.
isSuccessfulResponse
(
data
))
{
return
data
;
}
}
);
}
}
register
(
formData
):
Observable
<
any
>
{
register
(
formData
):
Observable
<
any
>
{
formData
.
environment
=
this
.
env
;
formData
.
environment
=
this
.
env
;
return
this
.
apiService
.
post
(
'svc/RegisterMyCareerUser'
,
formData
);
return
this
.
apiService
.
post
(
'svc/RegisterMyCareerUser'
,
formData
)
.
map
(
data
=>
{
if
(
this
.
utilsService
.
isSuccessfulResponse
(
data
))
{
return
data
;
}
}
);
}
}
reset
(
formData
):
Observable
<
any
>
{
reset
(
formData
):
Observable
<
any
>
{
formData
.
environment
=
this
.
env
;
formData
.
environment
=
this
.
env
;
return
this
.
apiService
.
post
(
'svc/PasswordChange'
,
formData
);
return
this
.
apiService
.
post
(
'svc/PasswordChange'
,
formData
)
.
map
(
data
=>
{
if
(
this
.
utilsService
.
isSuccessfulResponse
(
data
))
{
return
data
;
}
}
);
}
}
logout
(
formData
=
{}
as
any
):
Observable
<
any
>
{
logout
(
formData
=
{}
as
any
):
Observable
<
any
>
{
...
...
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