{"id":26063738,"url":"https://github.com/mavrick-1/causewaylogin","last_synced_at":"2025-06-25T08:07:01.647Z","repository":{"id":228242354,"uuid":"769125833","full_name":"MAVRICK-1/causewaylogin","owner":"MAVRICK-1","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-08T11:56:48.000Z","size":137,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-17T20:29:26.045Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://causewaylogin.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MAVRICK-1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-08T11:54:51.000Z","updated_at":"2024-03-17T20:29:27.383Z","dependencies_parsed_at":"2024-03-17T20:39:42.715Z","dependency_job_id":null,"html_url":"https://github.com/MAVRICK-1/causewaylogin","commit_stats":null,"previous_names":["mavrick-1/causewaylogin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MAVRICK-1/causewaylogin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAVRICK-1%2Fcausewaylogin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAVRICK-1%2Fcausewaylogin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAVRICK-1%2Fcausewaylogin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAVRICK-1%2Fcausewaylogin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MAVRICK-1","download_url":"https://codeload.github.com/MAVRICK-1/causewaylogin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAVRICK-1%2Fcausewaylogin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261832678,"owners_count":23216497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-08T17:18:41.245Z","updated_at":"2025-06-25T08:07:01.621Z","avatar_url":"https://github.com/MAVRICK-1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeBin - Secure Code Snippet Storage\n\nCodeBin is a web application built with Angular, Angular Material, NgRx, RxJS, and Firebase. It allows users to securely store and edit their code snippets in the cloud.\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg alt=\"Demo\" src=\"./Images/websiteImage.png\" /\u003e\n\u003c/div\u003e\n## Features\n\n- **Secure Storage**: Store your code snippets securely in the cloud using Firebase Authentication.\n- **Edit Code Snippets**: Easily edit your code snippets directly in the browser.\n- **GitHub and Google Authentication**: Sign in to CodeBin using your GitHub or Google account.\n- **Passwordless Email Authentication**: Sign in with your email by clicking a magic link sent to your inbox.\n- **Password Reset**: Reset your password easily if you forget it.\n- **Responsive Design**: Enjoy a seamless experience across various devices and screen sizes.\n\n## Getting Started\n\nTo get started with CodeBin, follow these steps:\n\n1. Clone the repository to your local machine:\n\n   ```bash\n   git clone https://github.com/MAVRICK-1/causewaylogin\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   cd codebin\n   npm install\n   ```\n\n3. Set up Firebase:\n\n   - Create a Firebase project in the Firebase console.\n   - Enable Authentication and Firestore in your Firebase project.\n   - Copy your Firebase configuration and replace it in the `environments` files (`environment.ts` and `environment.prod.ts`) of your Angular project.\n\n4. Run the development server:\n\n   ```bash\n   ng serve\n   ```\n\n5. Open your browser and navigate to `http://localhost:4200/` to view CodeBin.\n\n## Demo\n\nWatch this [YouTube video](https://www.youtube.com/watch?v=_vIxsk2tQR8\u0026list=PL_CHDCAKedMzX2LWcA_WGHUqLnCUAF5V8) to see a demonstration of CodeBin in action.\n\n## Website\n\nAccess CodeBin at [Codebin](https://causewaylogin.vercel.app/).\n\nHere's the corrected markdown for the code snippets section:\n\n\n## Architecture\n\nThe authentication service (`AuthService`) manages user authentication using Firebase Authentication. Below is an overview of the key functions:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003esignInWithGithub()\u003c/b\u003e\u003c/summary\u003e\n\nSign in with a GitHub account using Firebase's GitHub provider.\n\n```typescript\nsignInWithGithub() {\n    const auth = getAuth();\n    signInWithPopup(auth, new GithubAuthProvider())\n        .then((result) =\u003e {\n            const credential = GithubAuthProvider.credentialFromResult(result)!;\n            const token = credential.accessToken;\n            const user = result.user;\n            // IdP data available using getAdditionalUserInfo(result)\n        }).catch((error) =\u003e {\n            const errorCode = error.code;\n            const errorMessage = error.message;\n            console.log(error);\n        });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003esignInWithGoogle()\u003c/b\u003e\u003c/summary\u003e\n\nSign in with a Google account using Firebase's Google provider.\n\n```typescript\nsignInWithGoogle() {\n    const auth = getAuth();\n    signInWithPopup(auth, new GoogleAuthProvider())\n        .then((result) =\u003e {\n            this.router.navigate(['/snippet']);\n            const credential = GoogleAuthProvider.credentialFromResult(result)!;\n            const token = credential.accessToken;\n            const user = result.user;\n            console.log(user);\n            // IdP data available using getAdditionalUserInfo(result)\n        }).catch((error) =\u003e {\n            const errorCode = error.code;\n            const errorMessage = error.message;\n            console.log(error);\n        });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003esignInWithEmailLinkAuth(email: string, path: string = '/loading')\u003c/b\u003e\u003c/summary\u003e\n\nSend a sign-in email link to the user's email address. The user clicks the link to sign in to the application.\n\n```typescript\nsignInWithEmailLinkAuth(email: string, path: string = '/loading') {\n    const auth = getAuth();\n    const actionCodeSettings: ActionCodeSettings = {\n        // URL you want to redirect back to. The domain (www.example.com) for this\n        // URL must be in the authorized domains list in the Firebase Console.\n        url: location.origin + this.location.prepareExternalUrl(path),\n        // This must be true.\n        handleCodeInApp: true,\n    }\n    sendSignInLinkToEmail(auth, email, actionCodeSettings)\n        .then(() =\u003e {\n            // The link was successfully sent. Inform the user.\n            // Save the email locally so you don't need to ask the user for it again\n            // if they open the link on the same device.\n            window.localStorage.setItem('emailForSignIn', email);\n            this.dialog.open(LinksendComponent)\n            console.log('email sent');\n            // ...\n        })\n        .catch((error) =\u003e {\n            const errorCode = error.code;\n            const errorMessage = error.message;\n            console.log(error);\n            // ...\n        });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003econfirmSignIn(url: string)\u003c/b\u003e\u003c/summary\u003e\n\nConfirm the sign-in link sent via email and sign the user into the application.\n\n```typescript\nconfirmSignIn(url: string) {\n    // Confirm the link is a sign-in with email link.\n    const auth = getAuth();\n    if (isSignInWithEmailLink(auth, window.location.href)) {\n        // Additional state parameters can also be passed via URL.\n        // This can be used to continue the user's intended action before triggering\n        // the sign-in operation.\n        // Get the email if available. This should be available if the user completes\n        // the flow on the same device where they started it.\n        let email = window.localStorage.getItem('emailForSignIn')!;\n        // The client SDK will parse the code from the link for you.\n        signInWithEmailLink(auth, email, window.location.href)\n            .then((result) =\u003e {\n                // Clear email from storage.\n                window.localStorage.removeItem('emailForSignIn');\n                // You can access the new user via result.user\n                // Additional user info profile not available via:\n                // result.additionalUserInfo.profile == null\n                // You can check if the user is new or existing:\n                // result.additionalUserInfo.isNewUser\n                this.router.navigate(['/snippet']);\n                console.log(result);\n            })\n            .catch((error) =\u003e {\n                // Some error occurred, you can inspect the code: error.code\n                // Common errors could be invalid email and invalid or expired OTPs.\n                console.log(error);\n                this.router.navigate(['/']);\n            });\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eregisterUser(email: string, password: string)\u003c/b\u003e\u003c/summary\u003e\n\nRegister a new user with email and password.\n\n```typescript\nregisterUser(email: string, password: string) {\n    const auth = getAuth();\n    createUserWithEmailAndPassword(auth, email, password)\n        .then((userCredential) =\u003e {\n            const user = userCredential.user;\n            this.dialog.open(SucesspopComponent);\n            this.router.navigate(['/snippet']);\n        })\n        .catch((error) =\u003e {\n            const errorMessage = error.message;\n            if (error.code === 'auth/email-already-in-use') {\n                this.dialog.open(EmailAlreadyexistComponent);\n            } else {\n                this.dialog.open(InvalidEmailComponent);\n            }\n        });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eloginUser(email:\n\n string, password: string)\u003c/b\u003e\u003c/summary\u003e\n\nLog in an existing user with email and password.\n\n```typescript\nloginUser(email: string, password: string) {\n    const auth = getAuth();\n    signInWithEmailAndPassword(auth, email, password)\n        .then((userCredential) =\u003e {\n            const user = userCredential.user;\n            this.router.navigate(['/snippet']);\n        })\n        .catch((error) =\u003e {\n            const errorCode = error.code;\n            const errorMessage = error.message;\n            this.dialog.open(InvalidemailpasswordComponent);\n        });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003elogout()\u003c/b\u003e\u003c/summary\u003e\n\nLog out the current user.\n\n```typescript\nlogout() {\n    const auth = getAuth();\n    signOut(auth).then(() =\u003e {\n        this.uid = undefined;\n        this.router.navigate(['/']);\n    }).catch((error) =\u003e {\n        console.log('Error occurred during signout:', error);\n    });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eresetPassword(email: string)\u003c/b\u003e\u003c/summary\u003e\n\nSend a password reset email to the user's email address.\n\n```typescript\nresetPassword(email: string) {\n    const auth = getAuth();\n    sendPasswordResetEmail(auth, email)\n        .then(() =\u003e {\n            this.dialog.open(LinksendComponent);\n        })\n        .catch((error) =\u003e {\n            console.log('Error occurred during password reset:', error);\n            this.dialog.open(LinksendComponent);\n        });\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003egetCurrentUser()\u003c/b\u003e\u003c/summary\u003e\n\nGet the current authenticated user.\n\n```typescript\ngetCurrentUser() {\n    return getAuth().currentUser;\n}\n```\n\n\u003c/details\u003e\n\nThe FireStoreService manages interactions with Firestore for storing, retrieving, updating, and deleting code snippets. Below is an overview of the key functions:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003ecreateSnippet(snippet: any)\u003c/b\u003e\u003c/summary\u003e\n\nCreate a new code snippet in Firestore for the current user.\n\n```typescript\nasync createSnippet(snippet: any) {\n    try {\n        const uid = this.authService.getUid();\n        const docRef = await addDoc(collection(this.db, `users/${uid}/codesamples`), {\n            ...snippet,\n            by: uid\n        });\n        console.log(\"Document written with ID: \", docRef.id);\n    } catch (e) {\n        console.error(\"Error adding document: \", e);\n        alert(\"error while creating\");\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003egetAllSnippet()\u003c/b\u003e\u003c/summary\u003e\n\nRetrieve all code snippets stored in Firestore for the current user.\n\n```typescript\nasync getAllSnippet() {\n    let result: any[] = []\n    const uid = window.localStorage.getItem('uid')\n    const querySnapshot = await getDocs(collection(this.db, `users/${uid}/codesamples`));\n    querySnapshot.forEach((doc) =\u003e {\n        result.push({ id: doc.id, ...doc.data() })\n    });\n    return result\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003egetSnippetById(docId: string)\u003c/b\u003e\u003c/summary\u003e\n\nRetrieve a specific code snippet by its ID from Firestore for the current user.\n\n```typescript\nasync getSnippetById(docId: string) {\n    const uid = window.localStorage.getItem('uid');\n    const docRef = doc(this.db, `users/${uid}/codesamples`, docId);\n    const docSnap = await getDoc(docRef);\n\n    if (docSnap.exists()) {\n        console.log(\"Document data:\", docSnap.data());\n        return docSnap.data();\n    } else {\n        console.log(\"No such document!\");\n        return {\n            id: \"1\",\n            title: \"not found\",\n            code: \"not found\"\n        };\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003edeleteSnippet(docId: string)\u003c/b\u003e\u003c/summary\u003e\n\nDelete a specific code snippet by its ID from Firestore for the current user.\n\n```typescript\nasync deleteSnippet(docId: string) {\n    try {\n        const uid = this.authService.getUid();\n        await deleteDoc(doc(this.db, `users/${uid}/codesamples`, docId));\n        console.log(\"Document deleted successfully\");\n        return true;\n    } catch (error) {\n        console.error(\"Error deleting document: \", error);\n        return false;\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eeditSnippet(docId: string, updatedSnippet: any)\u003c/b\u003e\u003c/summary\u003e\n\nUpdate a specific code snippet by its ID in Firestore for the current user.\n\n```typescript\nasync editSnippet(docId: string, updatedSnippet: any) {\n    try {\n        const uid = this.authService.getUid();\n        const docRef = doc(this.db, `users/${uid}/codesamples`, docId);\n        \n        await setDoc(docRef, updatedSnippet, { merge: true });\n\n        console.log(\"Document edited successfully\");\n        return true;\n    } catch (error) {\n        console.error(\"Error editing document: \", error);\n        return false;\n   \n\n }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eShareSnippetById(docId: string, uid: string)\u003c/b\u003e\u003c/summary\u003e\n\nRetrieve a specific code snippet by its ID from Firestore for a given user ID (used for sharing).\n\n```typescript\nasync ShareSnippetById(docId: string, uid: string) {\n    const docRef = doc(this.db, `users/${uid}/codesamples`, docId);\n    const docSnap = await getDoc(docRef);\n\n    if (docSnap.exists()) {\n        console.log(\"Document data:\", docSnap.data());\n        return docSnap.data();\n    } else {\n        console.log(\"No such document!\");\n        return {\n            id: \"1\",\n            title: \"not found\",\n            code: \"not found\"\n        };\n    }\n}\n```\n\n\u003c/details\u003e\n\n\n\n\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavrick-1%2Fcausewaylogin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmavrick-1%2Fcausewaylogin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavrick-1%2Fcausewaylogin/lists"}