Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
portal-apps-manage
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
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
angular
portal-apps-manage
Commits
c0c70745
Commit
c0c70745
authored
Aug 05, 2025
by
sawit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login myhr
parent
a138cf84
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
22 deletions
+60
-22
login.component.ts
src/app/authentication/login/login.component.ts
+34
-13
auth.service.ts
src/app/shared/services/auth.service.ts
+18
-7
user-auth.model.ts
src/app/shared/user-auth.model.ts
+7
-2
environment.ts
src/environments/environment.ts
+1
-0
No files found.
src/app/authentication/login/login.component.ts
View file @
c0c70745
...
...
@@ -113,21 +113,42 @@ export class LoginComponent {
}
}
// login() {
// this.showLoader = true;
// let body: LoginModel = new LoginModel();
// body.username = this.username;
// body.password = this.password;
// this.authService.login(this.loginForm.controls['username'].value, this.loginForm.controls['password'].value).subscribe(result => {
// console.log(result)
// this.tokenService.saveToken(result.accessToken);
// this.tokenService.saveUser(result);
// this.routes.navigate(['/admin/pdpa-manage'])
// }, (error) => {
// this.showLoader = false;
// this.error = 'Username หรือ Password ไม่ถูกต้อง';
// })
// }
login
()
{
this
.
showLoader
=
true
;
let
body
:
LoginModel
=
new
LoginModel
();
body
.
username
=
this
.
username
;
body
.
password
=
this
.
password
;
this
.
authService
.
login
(
this
.
loginForm
.
controls
[
'username'
].
value
,
this
.
loginForm
.
controls
[
'password'
].
value
).
subscribe
(
result
=>
{
console
.
log
(
result
)
this
.
tokenService
.
saveToken
(
result
.
accessToken
);
this
.
tokenService
.
saveUser
(
result
);
this
.
routes
.
navigate
([
'/admin/pdpa-manage'
])
},
(
error
)
=>
{
this
.
showLoader
=
false
;
this
.
error
=
'Username หรือ Password ไม่ถูกต้อง'
;
})
let
loginCredentials
:
LoginModel
=
new
LoginModel
();
loginCredentials
.
username
=
this
.
loginForm
.
controls
[
'username'
].
value
;
loginCredentials
.
password
=
this
.
loginForm
.
controls
[
'password'
].
value
;
this
.
authService
.
login
(
loginCredentials
).
subscribe
({
next
:
(
response
)
=>
{
console
.
log
(
'Login successful'
,
response
);
// Assuming your API returns a token, store it
if
(
response
.
accessToken
)
{
this
.
tokenService
.
saveToken
(
response
.
accessToken
);
}
this
.
routes
.
navigate
([
'/myjob/pdpa-manage'
]);
},
error
:
(
error
)
=>
{
console
.
error
(
'Login failed'
,
error
);
// Handle login error, e.g., display an error message to the user
}
});
}
// adminCompanyList(memberId: string) {
...
...
src/app/shared/services/auth.service.ts
View file @
c0c70745
import
{
Injectable
,
NgZone
}
from
'@angular/core'
;
import
{
HttpClient
}
from
'@angular/common/http'
;
import
{
ProfileModel
,
UserModel
}
from
'../user-auth.model'
;
import
{
LoginModel
,
ProfileModel
,
UserModel
}
from
'../user-auth.model'
;
import
{
environment
}
from
'../../../environments/environment'
;
import
{
Observable
}
from
'rxjs'
;
@
Injectable
({
providedIn
:
'root'
,
})
export
class
AuthService
{
apiBaseUrl
=
"/auth/company"
;
private
apiUrl
=
environment
.
jbossUrl
+
'/usapi'
;
//add
constructor
(
private
http
:
HttpClient
,
)
{
}
login
(
username
:
string
,
password
:
string
)
{
const
body
=
{
username
:
username
,
password
:
password
,
};
return
this
.
http
.
post
<
UserModel
>
(
this
.
apiBaseUrl
+
'/login'
,
body
)
// login(username: string, password: string) {
// const body = {
// username: username,
// password: password,
// };
// return this.http.post<UserModel>(this.apiBaseUrl + '/login', body)
// }
login
(
credentials
:
LoginModel
):
Observable
<
UserModel
>
{
credentials
.
dbName
=
credentials
.
dbName
||
'DB'
;
credentials
.
dbcomp
=
credentials
.
dbcomp
||
'100'
;
credentials
.
lang
=
credentials
.
lang
||
'tha'
;
return
this
.
http
.
post
<
UserModel
>
(
`
${
this
.
apiUrl
}
/authen`
,
credentials
);
}
refreshToken
(
token
:
string
)
{
...
...
src/app/shared/user-auth.model.ts
View file @
c0c70745
...
...
@@ -2,8 +2,13 @@ import { EmployeeModel } from "../DPU/models/employee.model";
import
{
UserProfileModel
}
from
"../DPU/models/user.model"
;
export
class
LoginModel
{
public
username
:
string
=
""
;
public
password
:
string
=
""
;
// public username: string = "";
// public password: string = "";
username
?:
string
;
//add
password
?:
string
;
//add
dbName
?:
string
;
//add
dbcomp
?:
string
;
//add
lang
?:
string
;
//add
}
...
...
src/environments/environment.ts
View file @
c0c70745
...
...
@@ -5,6 +5,7 @@ export const environment = {
production
:
false
,
baseUrl
:
'https://myjob-uat.myhr.co.th/api'
,
url
:
'https://portal.myhr.co.th/api/'
,
jbossUrl
:
'https://hrplus.myhr.co.th/hr'
,
//add
portalFixedToken
:
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZSI6InVzZXIiLCJpc3MiOiJDb21wdXRlciBTY2llbmNlIENvcnBvcmF0aW9uIExpbWl0ZWQiLCJmdWxsTmFtZSI6InRlZXJhZGFjaCBrdWhhdGFuYXNhdGllbiIsIm1lbWJlcklkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0In0.FO7u8g7KfzkmZFTuuniBCEQxduPjcvzMbH7iug3DT90'
,
firebase
:
{
apiKey
:
"***************************************"
,
...
...
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