Skip to content

Commit

Permalink
Fiebase_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
AishaAgarwal committed Jan 9, 2024
1 parent 4c10cba commit ff94a64
Show file tree
Hide file tree
Showing 49 changed files with 217 additions and 98 deletions.
28 changes: 27 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
enter your firebase service accounts and project variables here
SERVICE_ENV=development
HOST=127.0.0.1
PORT=8000
API_KEY=AIzaSyB_tOjzX6Em41dcetUBf1pqaOY4pU-E-kM
AUTH_DOMAIN=translate-fe564.firebaseapp.com
DATABASE_URL=https://translate-fe564-default-rtdb.firebaseio.com/
PROJECT_ID=translate-fe564
STORAGE_BUCKET=translate-fe564.appspot.com
MESSAGING_SENDER_ID=186396337537
APP_ID=1:186396337537:web:77729bd3347a8d3a933480
MEASUREMENT_ID=G-T4CXD6SY5G



FIREBASE_ACCOUNT_TYPE=service_account
FIREBASE_PROJECT_ID=translate-fe564
FIREBASE_PRIVATE_KEY_ID=2e4a746ba666c81889c594dac6abbd7399c6b7ce
FIREBASE_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDJo6weiI0i7xoG\nksZMs/edWV73LTzrOYmUPrtiYARYZwvFzHjtkUTNVjkho7vBerLTbrl1xxcYHPhj\npEchDPq8lOY+Xnby1CcYy5iqHQXVxjyWw9VbaPzoB7nnFk/FG/lUQPhKUoOxOjjI\n4pt+sAcuw+y+5IiD7LGHktMAMxy7KexkWJjkcx9xlaiEuA1sVmTIXiz1CGFAXc97\nzgCSsn4I8VKbhDtq3qIn+g17uVMu0T3+gUDGgz/a/c34EVYhRkcjpMlO/hPoMx4g\nwnxv1vAZkyGyjkHMZOjGLFxdnmqtvp8bDAdMeoHCy9gqNXk/Izz7/ajlAJJKkUbP\nmrTSeXrdAgMBAAECggEAGu0LzXH/otQZ/hm4eEKqBK2MBGbalTC0QgMUg8D9o45z\nIIE6/sJ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sWwnOFWKtEWiKFG8DbJ2TpECLtXiiIXgYGzKQO\nOTNOb6ZfZ2AmtMIvpxzCPKtnv2kRdt1PKp6VXlDr0WVqKKc+/O3tJ/RwMMKvEWBK\nPQAw14UomNhQFnpeyxtsK/A=\n-----END PRIVATE KEY-----\n
FIREBASE_CLIENT_EMAIL=[email protected]
FIREBASE_CLIENT_ID=106650411189339404056
FIREBASE_AUTH_URI=https://accounts.google.com/o/oauth2/auth
FIREBASE_TOKEN_URI=https://oauth2.googleapis.com/token
FIREBASE_AUTH_PROVIDER_X509_CERT_URL=https://www.googleapis.com/oauth2/v1/certs
FIREBASE_CLIENT_X509_CERT_URL=https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-a8gi7%40translate-fe564.iam.gserviceaccount.com
# universe_domain=googleapis.com


Binary file modified account/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified account/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file modified account/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file modified account/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified account/__pycache__/serializers.cpython-39.pyc
Binary file not shown.
Binary file modified account/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified account/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified account/views/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified account/views/__pycache__/login.cpython-39.pyc
Binary file not shown.
Binary file modified account/views/__pycache__/logout.cpython-39.pyc
Binary file not shown.
Binary file modified account/views/__pycache__/register.cpython-39.pyc
Binary file not shown.
7 changes: 4 additions & 3 deletions custom_static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function myFunction5() {


function updateProgressBar() {
// Make an AJAX request to get the progress
// // Make an AJAX request to get the progress
$.ajax({
url: '/get_progress',
type: 'GET',
Expand All @@ -154,7 +154,8 @@ function updateProgressBar() {
console.error('Error fetching progress:', error);
}
});
}
}

// Call updateProgressBar function every few seconds
setInterval(updateProgressBar, 3000); // Adjust the interval as needed
setInterval(updateProgressBar, 3000);
// Adjust the interval as needed
Binary file modified job/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified job/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file modified job/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file modified job/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified job/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified job/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified job/views/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified job/views/__pycache__/list.cpython-39.pyc
Binary file not shown.
Binary file modified job/views/__pycache__/lu_language.cpython-39.pyc
Binary file not shown.
Binary file modified job/views/__pycache__/upload.cpython-39.pyc
Binary file not shown.
Binary file modified plan/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified plan/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file modified plan/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file modified plan/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified plan/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified plan/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified plan/views/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified plan/views/__pycache__/lu_plan.cpython-39.pyc
Binary file not shown.
Binary file modified plan/views/__pycache__/update.cpython-39.pyc
Binary file not shown.
278 changes: 186 additions & 92 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,131 @@
<!DOCTYPE html>
{% load static %}

<html >
<head>
<title>Hello World!</title>

<!--Video upload & dropdown box-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script class="jsbin" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<!--Modal-->
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

<!--link to css / js -->
<link rel='stylesheet' type="text/css" href="{% static 'css/main.css' %}">
<script type="text/javascript" src="{% static 'js/main.js' %}"></script>

<!-- Bootstrap Icon CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">

</head>
<body>

<ul>
<li><h1 href="", id="logo">LOGO</h1></li>
<li style="float:right">
<button class="button" id="signin", onclick="document.getElementById('id01').style.display='block'">
<i class="bi bi-box-arrow-in-right"><i class='no-italics'> Sign In
</i></i>
</button>
</li>
</ul>

<!---Video upload --->
<div class="file-upload">
<form action="{% url 'job:upload' %}" enctype="multipart/form-data" method="POST">

<html>
<head>
<title>Hello World!</title>

<!--Video upload & dropdown box-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
class="jsbin"
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
></script>

<!--Modal-->
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />

<!--link to css / js -->
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}" />
<script type="text/javascript" src="{% static 'js/main.js' %}"></script>

<!-- Bootstrap Icon CSS -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
/>

<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.1.1/firebase-app.js";

import {
getAuth,
signInWithPopup,
GoogleAuthProvider,
signInWithRedirect,
} from "https://www.gstatic.com/firebasejs/9.1.1/firebase-auth.js";

const firebaseConfig = {
apiKey: "AIzaSyB_tOjzX6Em41dcetUBf1pqaOY4pU-E-kM",
authDomain: "translate-fe564.firebaseapp.com",
databaseURL: "https://translate-fe564-default-rtdb.firebaseio.com",
projectId: "translate-fe564",
storageBucket: "translate-fe564.appspot.com",
messagingSenderId: "186396337537",
appId: "1:186396337537:web:70525a799bc854c3933480",
measurementId: "G-17XNH66CVV",
};

const app = initializeApp(firebaseConfig);

const auth = getAuth(app);

const provider = new GoogleAuthProvider();
auth.onAuthStateChanged((user) => {
if (user) {

window.location = "dashboard_2";
console.log(user); //After successful login, user will be redirected to home.html
}
});

function signInWithGoogle() {
signInWithRedirect(auth, provider);
}
document
.querySelector("#btnsignIn")
.addEventListener("click", signInWithGoogle);

function loguser() {
console.log(auth.currentUser);
}

document.querySelector("#btnLog").addEventListener("click", loguser);
</script>
</head>
<body>
<ul>
<li><h1 href="" , id="logo">LOGO</h1></li>
<li style="float: right">
<button
class="button"
id="signin"
,
onclick="document.getElementById('id01').style.display='block'"
>
<i class="bi bi-box-arrow-in-right"
><i class="no-italics"> Sign In </i></i
>
</button>
</li>
</ul>

<!---Video upload --->
<div class="file-upload">
<form
action="{% url 'job:upload' %}"
enctype="multipart/form-data"
method="POST"
>
<label class="custom-file-upload">
<input type="file" name="video" accept=".mp4" class="fileuploader" >
</label>
<input type="file" name="video" accept=".mp4" class="fileuploader" />
</label>
<ul>
<li><button class="Upload"></button></li>
<li><button class="Upload"></button></li>
</ul>
</form>
<i class="bi bi-upload"></i>
<h1 >Drop to upload</h1>
<p >(up to 500MB)</p>
<p id=text1>mp4, quicktime, webm are supported</p>
<div class="video-list">
<ul style=list-style:none;></ul>
</div>
</div>

<div class="file-requirements">
<p class="thick"><i class="bi bi-info-circle"><i class='no-italics'> Requirements</i></i></p>
</div>

<!---language dropdown --->
<div class="dropdown-wrapper">
<form method="POST" action="{% url 'dashboard_1' %}">
<select name="select1" class="dropbtn"> <!-- note the name -->
<i style="float:right", class="bi bi-chevron-down"></i>
</form>
<i class="bi bi-upload"></i>
<h1>Drop to upload</h1>
<p>(up to 500MB)</p>
<p id="text1">mp4, quicktime, webm are supported</p>
<div class="video-list">
<ul style="list-style: none"></ul>
</div>
</div>

<div class="file-requirements">
<p class="thick">
<i class="bi bi-info-circle"><i class="no-italics"> Requirements</i></i>
</p>
</div>

<!---language dropdown --->
<div class="dropdown-wrapper">
<form method="POST" action="{% url 'dashboard_1' %}">
<select name="select1" class="dropbtn">
<!-- note the name -->
<i style="float: right" , class="bi bi-chevron-down"></i>
<option value="None">Choose a target language</option>
<option value="English">English</option>
<option value="Germany">Germany</option>
Expand All @@ -69,43 +134,72 @@ <h1 >Drop to upload</h1>
<option value="Portuguese">Portuguese</option>
<option value="Polish">Polish</option>
<option value="Swedish">Swedish</option>
</select>
</form>


<p id=text2><i class="bi bi-exclamation-triangle" id=triangle><i class='no-italics'> Please select an option</i></i></p>

<!---submission button --->

<button class="submit", onclick="document.getElementById('id01').style.display='block'">Translate this video</button>


</div>

<!-- Video card -->
<div class="w3-container">
<h1>Translated</h1>

<div class="w3-card-2">
<img src="{% static 'image/english.jpg' %}" alt="en" style="width:100%">
<p>Video title here<i class="bi bi-three-dots-vertical" style="float:right"></i></p>
</select>
</form>

<p id="text2">
<i class="bi bi-exclamation-triangle" id="triangle"
><i class="no-italics"> Please select an option</i></i
>
</p>

<!---submission button --->

<button
class="submit"
,
onclick="document.getElementById('id01').style.display='block'"
>
Translate this video
</button>
</div>

<div class="w3-card-2", id=box>
<img src="{% static 'image/spanish.jpg' %}" alt="sp" style="width:100%">
<p>Video title here<i class="bi bi-three-dots-vertical" style="float:right"></i></p>
<!-- Video card -->
<div class="w3-container">
<h1>Translated</h1>

<div class="w3-card-2">
<img
src="{% static 'image/english.jpg' %}"
alt="en"
style="width: 100%"
/>
<p>
Video title here<i
class="bi bi-three-dots-vertical"
style="float: right"
></i>
</p>
</div>

<div class="w3-card-2" , id="box">
<img
src="{% static 'image/spanish.jpg' %}"
alt="sp"
style="width: 100%"
/>
<p>
Video title here<i
class="bi bi-three-dots-vertical"
style="float: right"
></i>
</p>
</div>
</div>
</div>

<!-- Modal function -->
<div id="id01" class="modal">
<div class="container">
<h1>Sign in with Google</h1>
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span>
<button><a href='/login'><img src="{% static 'image/google-icon.png' %}"> Continue with Google</button>
</div>
</div>

</body>
<!-- Modal function -->
<div id="id01" class="modal">
<div class="container">
<h1>Sign in with Google</h1>
<!-- <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span> -->
<button id="btnsignIn">
<img src="{% static 'image/google-icon.png' %}" /> Continue with
Google
</button>
<button id="btnLog">
<img src="{% static 'image/google-icon.png' %}" /> Log
</button>
</div>
</div>
</body>
</html>

Binary file modified translate_panda/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified translate_panda/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified translate_panda/__pycache__/views.cpython-39.pyc
Binary file not shown.
Binary file modified translate_panda/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
Binary file modified translate_panda/settings/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified translate_panda/settings/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 0 additions & 2 deletions translate_panda/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def get(self, request):
return Response(json.dumps({'Message': 'Internal Server Error'}), status=status.HTTP_500_INTERNAL_SERVER_ERROR)



class ProtectedAreaView(APIView):
authentication_classes = [FirebaseAuthentication]
permission_classes = [IsAuthenticated]
Expand All @@ -38,7 +37,6 @@ def get(self, request):
return Response(json.dumps({'Message': 'Internal Server Error'}), status=status.HTTP_500_INTERNAL_SERVER_ERROR)



class DashboardOneView(APIView):
# authentication_classes = [FirebaseAuthentication]
# permission_classes = [IsAuthenticated]
Expand Down
Binary file modified utils/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified utils/__pycache__/basic.cpython-39.pyc
Binary file not shown.
Binary file modified utils/__pycache__/queue.cpython-39.pyc
Binary file not shown.
Binary file modified utils/__pycache__/read_write_file.cpython-39.pyc
Binary file not shown.
Binary file modified utils/auth/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified utils/auth/__pycache__/authentication.cpython-39.pyc
Binary file not shown.
Binary file modified utils/auth/__pycache__/exceptions.cpython-39.pyc
Binary file not shown.

0 comments on commit ff94a64

Please sign in to comment.