Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hdastageeri
hft_awado_app
Commits
e878023d
Commit
e878023d
authored
Nov 26, 2019
by
Ratnadeep Rajendra Kharade
Browse files
Integrated login with api call
parent
e329eaf8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app/app.module.ts
View file @
e878023d
...
...
@@ -10,11 +10,14 @@ import { AppComponent } from './app.component';
import
{
AppRoutingModule
}
from
'
./app-routing.module
'
;
import
{
Geolocation
}
from
'
@ionic-native/geolocation/ngx
'
;
import
{
HttpClientModule
}
from
'
@angular/common/http
'
;
@
NgModule
({
declarations
:
[
AppComponent
],
entryComponents
:
[],
imports
:
[
BrowserModule
,
HttpClientModule
,
IonicModule
.
forRoot
(),
AppRoutingModule
],
...
...
src/app/auth/login/login.page.html
View file @
e878023d
...
...
@@ -27,7 +27,7 @@
</div>
<div
padding
>
<ion-button
size=
"large"
expand=
"block"
(click)=
"
clickMe
()"
>
Login
</ion-button>
<ion-button
size=
"large"
expand=
"block"
(click)=
"
login
()"
>
Login
</ion-button>
</div>
</ion-col>
</ion-row>
...
...
src/app/auth/login/login.page.ts
View file @
e878023d
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
Observable
}
from
'
rxjs
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
@
Component
({
selector
:
'
app-login
'
,
templateUrl
:
'
./login.page.html
'
,
...
...
@@ -9,20 +12,33 @@ import { Router } from '@angular/router';
export
class
LoginPage
implements
OnInit
{
username
=
""
;
password
=
""
;
correctCredentials
=
false
;
correctCredentials
=
false
;
loginApi
:
Observable
<
any
>
;
constructor
(
private
router
:
Router
)
{
}
constructor
(
private
router
:
Router
,
public
httpClient
:
HttpClient
)
{
}
ngOnInit
()
{
}
clickMe
()
{
if
(
this
.
username
===
"
admin
"
&&
this
.
password
===
"
admin
"
||
this
.
username
===
"
demo
"
&&
this
.
password
===
"
demo
"
)
{
this
.
router
.
navigateByUrl
(
'
/home
'
);
}
else
{
this
.
correctCredentials
=
true
;
}
login
()
{
this
.
loginApiCall
();
}
loginApiCall
()
{
this
.
loginApi
=
this
.
httpClient
.
post
(
'
http://193.196.52.237:8081/authenticate
'
,
{
"
email
"
:
this
.
username
,
"
password
"
:
this
.
password
});
this
.
loginApi
.
subscribe
((
data
)
=>
{
console
.
log
(
'
my data:
'
,
data
);
this
.
router
.
navigateByUrl
(
'
/home
'
);
},
(
error
)
=>
{
console
.
log
(
error
);
this
.
correctCredentials
=
true
;
});
}
}
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!
Cancel
Please
register
or
sign in
to comment