Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-flutter
Project
Project
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
Ilham Maulana
library-app-flutter
Commits
5b790690
Commit
5b790690
authored
Jul 31, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: reset pasword confirm by pin sended with email
parent
99c75c17
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
328 additions
and
74 deletions
+328
-74
auth_provider.dart
lib/src/providers/auth_provider.dart
+55
-1
form_screen.dart
lib/src/screens/form_screen.dart
+14
-0
reset_password_form.dart
lib/src/widgets/forms/reset_password_form.dart
+259
-73
No files found.
lib/src/providers/auth_provider.dart
View file @
5b790690
...
...
@@ -5,7 +5,6 @@ import 'package:http/http.dart' as http;
import
'package:library_app/src/models/token.dart'
;
import
'package:library_app/src/models/user.dart'
;
// Flutter: make memberLoans adjustable to be filtered to near outstanding loan and overdued loan
class
AuthProvider
with
ChangeNotifier
{
String
baseUrl
=
'http://localhost:8000/api/v1'
;
...
...
@@ -18,6 +17,10 @@ class AuthProvider with ChangeNotifier {
bool
filterByUpcoming
=
false
;
bool
filterByOverdued
=
false
;
int
?
userIdResetPw
;
bool
resetPasswordTokenSended
=
false
;
bool
resetPasswordSucced
=
false
;
Future
<
void
>
signIn
(
String
username
,
String
password
)
async
{
try
{
final
response
=
await
http
.
post
(
...
...
@@ -161,6 +164,57 @@ class AuthProvider with ChangeNotifier {
}
}
Future
<
void
>
resetPassword
(
String
email
)
async
{
try
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$baseUrl
/reset-password/request-token'
),
body:
jsonEncode
({
"email"
:
email
}),
headers:
{
'Content-Type'
:
'application/json'
},
);
if
(
response
.
statusCode
==
200
)
{
final
data
=
jsonDecode
(
response
.
body
);
resetPasswordTokenSended
=
true
;
userIdResetPw
=
data
[
"user_id_reset_pw"
];
}
else
{
debugPrint
(
'Error reset user password:
${response.statusCode}
,
${response.body}
'
);
}
notifyListeners
();
}
catch
(
error
)
{
debugPrint
(
"Error reset user password:
$error
"
);
}
}
Future
<
void
>
confirmResetPassword
(
int
pin
,
String
password1
,
String
password2
)
async
{
final
body
=
jsonEncode
({
"pin"
:
pin
,
"password1"
:
password1
,
"password2"
:
password2
,
});
try
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$baseUrl
/reset-password/confirm'
),
body:
body
,
headers:
{
'Content-Type'
:
'application/json'
},
);
if
(
response
.
statusCode
==
200
)
{
resetPasswordSucced
=
true
;
}
else
{
debugPrint
(
'Error confirm reset user password:
${response.statusCode}
,
${response.body}
'
);
}
notifyListeners
();
}
catch
(
error
)
{
debugPrint
(
"Error confirm reset user password:
$error
"
);
}
}
Future
<
void
>
getMemberLoan
()
async
{
String
url
=
'
$baseUrl
/members/
${user?.accountId}
/loans/'
;
if
(
filterByUpcoming
)
{
...
...
lib/src/screens/form_screen.dart
View file @
5b790690
...
...
@@ -75,6 +75,20 @@ class ResetPasswordScreen extends StatelessWidget {
}
}
class
ConfirmResetPasswordScreen
extends
StatelessWidget
{
const
ConfirmResetPasswordScreen
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
String
title
=
"Reset Password"
;
return
FormScreen
(
title:
title
,
body:
const
ConfirmResetPasswordForm
(),
);
}
}
class
ProfileEditScreen
extends
StatelessWidget
{
const
ProfileEditScreen
({
super
.
key
,
...
...
lib/src/widgets/forms/reset_password_form.dart
View file @
5b790690
This diff is collapsed.
Click to expand it.
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