A Firebase Authentication (v4) with Material Components user interface, UI, template. Sign in with a token from your favorite social media platform or via email. This is an excellent starting point for your next Firebase web project.
- Single page app implementation
- Paste in your firebase project parameters and go
- Account changes require email verification
- Mobile First User Interface
- Responsive CSS GRID layout
- Material Components UI
- photoURL resolution upgrades
- Gravatar fallback for all accounts with an email address
- Fallback avatar for 404 photoURL's
- Promise based functions aligned with Firebase documentation
- Simple JavaScript URL Argument Getter / Setter w Switch
- Create a Firebase project from the Firebase console.
- Under the Overview section click on "Add Firebase to your web app".
- Paste these configuration parameters in
script.js
.
- Paste these configuration parameters in
- From the Firebase console, go to Authentication.
- Enable All forms of Authentication.
- Under the Templates Tab, remove
/__/auth/action
from the Action URL - we don't need it. - Keep the query parameters in the Action URL (the text after the ?).
- Enable Firestore as your database.
- From the online console, add a new collection named
validator
and add afield
"secret"
with value of"foo"
.- This is going to be used for determining the privilege level of users. Our script will try and read this and if successful we know the user is an administrator.
- Paste the following rules into your
firestore.rules
file. NOTE: change theuid
to youruid
. Yours will be different. This is your administratoruid
with write privileges.
- From the online console, add a new collection named
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read,write: if request.auth.uid == "8FwcgfTAk6T6VOWmNWu5I47BI7g1";
}
match /users/{userId} {
allow read, write: if request.auth.uid == userId;
}
match /images {
allow read;
}
match /quotes {
allow read;
}
}
}
- Enable Firebase Storage.
- Paste the following rules into your
storage.rules
file. NOTE: change theuid
to your `uid.
- Paste the following rules into your
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read;
allow write: if request.auth.uid == "8FwcgfTAk6T6VOWmNWu5I47BI7g1";
}
}
}
- Notice how the "Admin" section appears only for administrators?
- Can you extend the app to have a multi-level admin? How about allowing users to vote on quotes or images?
If you found a bug, have any questions or want to contribute or collaborate please let me know.
Copyright 2018 Ronnie Smith, https://ronnievsmith.com All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License