Skip to content

Commit

Permalink
Merge pull request #252 from himanshugoyal77/fix-otp-verification
Browse files Browse the repository at this point in the history
Fix otp verification
  • Loading branch information
Akshatji800 authored Feb 2, 2025
2 parents 4bc9d17 + a6ab3cf commit 24e8f54
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/config/graphql_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class GraphQLConfig {
await _getToken();
final AuthLink authLink = AuthLink(getToken: () async => '$token');
final Link finalAuthLink = authLink.concat(httpLink);
print("link: $finalAuthLink");
return GraphQLClient(
cache: GraphQLCache(partialDataPolicy: PartialDataCachePolicy.accept),
link: finalAuthLink,
Expand Down
10 changes: 6 additions & 4 deletions lib/core/queries/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ class AuthQueries {
''';
}

String sendVerficationCode() {
String sendVerficationCode(String? email) {
return '''
mutation{
sendVerificationCode
sendVerificationCode(email: "$email")
}
''';
}

String completeVerificationCode() {
String completeVerificationCode(String? userId) {
return '''
mutation{
completeVerification{
completeVerification(
userId: "$userId"
){
_id
email
name
Expand Down
2 changes: 2 additions & 0 deletions lib/core/services/location_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class LocationService {
Position? get currentPosition => _currentPosition;

Future<Position?> getCurrentLocation() async {
// ignore: unused_local_variable
bool serviceEnabled;
// ignore: unused_local_variable
LocationPermission permission;

serviceEnabled = await Geolocator.isLocationServiceEnabled();
Expand Down
12 changes: 7 additions & 5 deletions lib/data/datasource/remote/remote_auth_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ class RemoteAuthApi {
if (!isConnected) {
return DataFailed('Beacon is trying to connect with internet...');
}

final QueryResult result = await _authClient.mutate(
MutationOptions(document: gql(_authQueries.sendVerficationCode())));
final UserModel? user = await localApi.fetchUser();
final QueryResult result = await _authClient.mutate(MutationOptions(
document: gql(_authQueries.sendVerficationCode(
user!.email,
))));

if (result.data != null && result.isConcrete) {
return DataSuccess(result.data!['sendVerificationCode'] as String);
Expand All @@ -218,11 +220,11 @@ class RemoteAuthApi {
if (!isConnected) {
return DataFailed('Beacon is trying to connect with internet...');
}

final UserModel? user = await localApi.fetchUser();
var authClient = await graphqlConfig.authClient();

final QueryResult result = await authClient.mutate(MutationOptions(
document: gql(_authQueries.completeVerificationCode())));
document: gql(_authQueries.completeVerificationCode(user!.id))));

if (result.data != null && result.isConcrete) {
var user = UserModel.fromJson(result.data!['completeVerification']);
Expand Down
7 changes: 4 additions & 3 deletions lib/presentation/hike/hike_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _HikeScreenState extends State<HikeScreen>
void initState() {
WidgetsBinding.instance.addObserver(this);
_hikeCubit.startHike(widget.beacon.id!, this, context);
SimplePip().setAutoPipMode(aspectRatio: [2, 3]);
SimplePip().setAutoPipMode(aspectRatio: (2, 3));
super.initState();
}

Expand Down Expand Up @@ -97,7 +97,7 @@ class _HikeScreenState extends State<HikeScreen>
),
controller: _panelController,
maxHeight: 60.h,
minHeight: isSmallsized ? 22.h : 18.h,
minHeight: isSmallsized ? 22.h : 20.h,
panel: _SlidingPanelWidget(),
collapsed: _collapsedWidget(),
body: _mapScreen()),
Expand Down Expand Up @@ -212,7 +212,7 @@ class _HikeScreenState extends State<HikeScreen>
alignment: Alignment.center,
child: Container(
alignment: Alignment.center,
height: 0.5.h,
height: 0.8.h,
width: 18.w,
decoration: BoxDecoration(
color: Colors.white,
Expand All @@ -233,6 +233,7 @@ class _HikeScreenState extends State<HikeScreen>
Gap(2),
Text('Beacon leader at: ${leaderAddress ?? '<>'}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
color: Colors.white,
Expand Down

0 comments on commit 24e8f54

Please sign in to comment.