This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from piyushkumar12111111/main
updatedCode
- Loading branch information
Showing
24 changed files
with
1,037 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package handlers | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/piyushkumar/hotelsystem/models" | ||
) | ||
|
||
// AddHotel adds a new hotel to the list. | ||
func AddHotel(w http.ResponseWriter, r *http.Request) { | ||
var hotel models.Hotel | ||
if err := json.NewDecoder(r.Body).Decode(&hotel); err != nil { | ||
http.Error(w, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
|
||
hotels = append(hotels, hotel) // Add the hotel to the in-memory store | ||
|
||
w.WriteHeader(http.StatusCreated) | ||
json.NewEncoder(w).Encode(hotel) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
"github.com/gorilla/mux" | ||
) | ||
|
||
// DeleteHotel removes a hotel from the list based on its ID. | ||
func DeleteHotel(w http.ResponseWriter, r *http.Request) { | ||
id := mux.Vars(r)["id"] | ||
|
||
for index, hotel := range hotels { | ||
if hotel.ID == id { | ||
// Remove the hotel from the slice | ||
hotels = append(hotels[:index], hotels[index+1:]...) | ||
w.WriteHeader(http.StatusNoContent) | ||
return | ||
} | ||
} | ||
|
||
http.Error(w, "Hotel not found", http.StatusNotFound) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package handlers | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/piyushkumar/hotelsystem/models" | ||
) | ||
|
||
// In-memory store for demonstration | ||
var hotels = []models.Hotel{ | ||
{ID: "1", Name: "Hotel Sunshine", Location: "California", Rating: 5}, | ||
{ID: "2", Name: "Grand Plaza", Location: "New York", Rating: 4}, | ||
} | ||
|
||
// ListHotels sends a list of hotels as a JSON response. | ||
func ListHotels(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Content-Type", "application/json") | ||
json.NewEncoder(w).Encode(hotels) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package models | ||
|
||
// Hotel represents the hotel model. | ||
type Hotel struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Location string `json:"location"` | ||
Rating int `json:"rating"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1 | ||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
# # This file configures the analyzer, which statically analyzes Dart code to | ||
# # check for errors, warnings, and lints. | ||
# # | ||
# # The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# # invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
# # The following line activates a set of recommended lints for Flutter apps, | ||
# # packages, and plugins designed to encourage good coding practices. | ||
# include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
# linter: | ||
# # The lint rules applied to this project can be customized in the | ||
# # section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# # included above or to enable additional rules. A list of all available lints | ||
# # and their documentation is published at | ||
# # https://dart-lang.github.io/linter/lints/index.html. | ||
# # | ||
# # Instead of disabling a lint rule for the entire project in the | ||
# # section below, it can also be suppressed for a single line of code | ||
# # or a specific dart file by using the `// ignore: name_of_lint` and | ||
# # `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# # producing the lint. | ||
# rules: | ||
# # avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options | ||
# # Additional information about this file can be found at | ||
# # https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "259327151092", | ||
"project_id": "checking-89b41", | ||
"storage_bucket": "checking-89b41.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:259327151092:android:6111def00b69cc17a587a1", | ||
"android_client_info": { | ||
"package_name": "com.example.firebase2" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyA-T8G-r-9mPeqt7kaPkjv_lJk7c-tl3I4" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:259327151092:android:3232e9c4f0403779a587a1", | ||
"android_client_info": { | ||
"package_name": "com.example.hotel_booking" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyA-T8G-r-9mPeqt7kaPkjv_lJk7c-tl3I4" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:259327151092:android:2ee71df70004724da587a1", | ||
"android_client_info": { | ||
"package_name": "com.firebasechekcing.projectchecking" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "259327151092-s0641c8r7b85mrdrseugtopkor64nrf9.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.firebasechekcing.projectchecking", | ||
"certificate_hash": "e7a299b8e5bb449e34c6138c33229aeeadc36d7f" | ||
} | ||
}, | ||
{ | ||
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyA-T8G-r-9mPeqt7kaPkjv_lJk7c-tl3I4" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "259327151092-s30bock1m3icqseijni1f0mh7dbq4jn1.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Frontend/lib/Screen/Authentication/controller/googlesignin.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_sign_in/google_sign_in.dart'; | ||
import 'package:hotel_booking/Screen/Home/home.dart'; | ||
|
||
class AuthService { | ||
final FirebaseAuth _auth = FirebaseAuth.instance; | ||
final GoogleSignIn googleSignIn = GoogleSignIn(); | ||
|
||
Future<User?> signInWithGoogle(BuildContext context) async { | ||
try { | ||
final GoogleSignInAccount? googleSignInAccount = | ||
await googleSignIn.signIn(); | ||
if (googleSignInAccount != null) { | ||
final GoogleSignInAuthentication googleSignInAuthentication = | ||
await googleSignInAccount.authentication; | ||
final AuthCredential credential = GoogleAuthProvider.credential( | ||
accessToken: googleSignInAuthentication.accessToken, | ||
idToken: googleSignInAuthentication.idToken, | ||
); | ||
final UserCredential authResult = | ||
await _auth.signInWithCredential(credential); | ||
final User? user = authResult.user; | ||
|
||
if (user != null) { | ||
// Navigate to the HomeScreen if the sign in was successful | ||
|
||
// Use the user's name and email | ||
String name = user.displayName ?? "No name available"; | ||
String email = user.email ?? "No email available"; | ||
|
||
// For demonstration, let's print these values | ||
print("Name: $name"); | ||
print("Email: $email"); | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => Home(), | ||
)); | ||
} | ||
return user; | ||
} | ||
} catch (error) { | ||
print(error.toString()); | ||
return null; | ||
} | ||
} | ||
|
||
Future<void> signOutGoogle() async { | ||
await googleSignIn.signOut(); | ||
await _auth.signOut(); | ||
} | ||
} |
Oops, something went wrong.