AmitXShukla / Online-School-Management-App-Angular-Firebase

Angular 11.0 Firebase App - Online School , Student Management App
184 stars 88 forks source link

Notifications not being displayed when logged in with correct passcode as a student or as a parent. #14

Closed sreyashi-123 closed 3 years ago

AmitXShukla commented 4 years ago

Thanks for opening this issue, can you please include a screen shot of your web browser console, your terminal window showing exact error.

sreyashi-123 commented 4 years ago

I will give the screenshots.Also I will post some other issues as well.Also you can check my repo:-(github.com/sreyashi-123/angular-firebase-project)for the code which is same as yours that you had uploaded in GitHub.still if you find any error you can mention. Thanks, Sreyashi

On Mon, Apr 6, 2020, 9:59 PM Amit Shukla notifications@github.com wrote:

Thanks for opening this issue, can you please include a screen shot of your web browser console, your terminal window showing exact error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AmitXShukla/Online-School-Management-App-Angular-Firebase/issues/14#issuecomment-609899545, or unsubscribe https://github.com/notifications/unsubscribe-auth/APCSH5O3EKVYUHCXINGBU3LRLH7PNANCNFSM4MCNH75Q .

sreyashi-123 commented 4 years ago

https://github.com/sreyashi-123/angular-firebase-project

This is the repo link

On Mon, Apr 6, 2020, 10:05 PM SREYASHI MUKHERJEE sreyashi1995@gmail.com wrote:

I will give the screenshots.Also I will post some other issues as well.Also you can check my repo:-( github.com/sreyashi-123/angular-firebase-project)for the code which is same as yours that you had uploaded in GitHub.still if you find any error you can mention. Thanks, Sreyashi

On Mon, Apr 6, 2020, 9:59 PM Amit Shukla notifications@github.com wrote:

Thanks for opening this issue, can you please include a screen shot of your web browser console, your terminal window showing exact error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AmitXShukla/Online-School-Management-App-Angular-Firebase/issues/14#issuecomment-609899545, or unsubscribe https://github.com/notifications/unsubscribe-auth/APCSH5O3EKVYUHCXINGBU3LRLH7PNANCNFSM4MCNH75Q .

sreyashi-123 commented 4 years ago

screenshot of error.docx

AmitXShukla commented 4 years ago

Here is what I suggest, please update this rule for this collection, make everything read, write = true and see if this fixes your problem. and if does, I can suggest where the problem is. change below ---- match /SMS_USERS/{document} { allow create: if exists(/databases/$(database)/documents/SMS_ROLES/$(request.resource.data.secretKey)) && get(/databases/$(database)/documents/SMS_ROLES/$(request.resource.data.secretKey)).data.role == request.resource.data.role; allow update: if exists(/databases/$(database)/documents/SMS_ROLES/$(request.resource.data.secretKey)) && get(/databases/$(database)/documents/SMS_ROLES/$(request.resource.data.secretKey)).data.role == request.resource.data.role && isDocOwner(); allow read: if isSignedIn() && isDocOwner(); }

to --- match /SMS_USERS/{document} { allow create: if true; allow update: if true; allow read: if true; }

sreyashi-123 commented 4 years ago

Did you ask me to do this?I have pasted below my rules after changing but it behaves the same just like before where on logging in as student we donot get to see any notifications and get that error message telling missing or insufficient permissions. rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { // SMS App Rules START match /SMS_ROLES/{document} { allow read, write: if true; } match /SMS_USERS/{document} { allow create: if true; allow update: if true; allow read: if true; } match /SMS_CONFIG_ENROLL_CD/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_CONFIG_FEE_CD/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_CONFIG_MARKS_CD/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_STUDENTS/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_STUDENTS/{document}/notifications/{doc} { allow read: if isSignedIn(); } match /SMS_FEE/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_MARKS/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_EMPLOYEE/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff(); } match /SMS_SALARY/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff(); } match /SMS_SALARY_CD/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff(); } match /SMS_VOUCHER/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff(); } match /SMS_EXPENSES/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff(); } match /SMS_ASSIGNMENT/{document} { allow read, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); allow write: if true; } match /SMS_CLASSES/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_HOMEWORK/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } match /SMS_TUTORIALS/{document} { allow read, write, delete: if isSMSAdmin() || isSMSStaff() || isSMSTeacher(); } function isSMSAdmin() { return get(/databases/$(database)/documents/SMS_USERS/$(request.auth.uid)).data.role == 'admin'; } function isSMSStaff() { return get(/databases/$(database)/documents/SMS_USERS/$(request.auth.uid)).data.role == 'staff'; } function isSMSParent() { return get(/databases/$(database)/documents/SMS_USERS/$(request.auth.uid)).data.role == 'parent'; } function isSMSTeacher() { return get(/databases/$(database)/documents/SMS_USERS/$(request.auth.uid)).data.role == 'teacher'; } function isSMSStudent() { return get(/databases/$(database)/documents/SMS_USERS/$(request.auth.uid)).data.role == 'student'; } function isDocOwner(){ // assuming document has a field author which is uid // Only the authenticated user who authored the document can read or write return request.auth.uid == resource.data.author; // This above read query will fail // The query fails even if the current user actually is the author of every story document. // The reason for this behavior is that when Cloud Firestore applies your security rules, // it evaluates the query against its potential result set, // not against the actual properties of documents in your database. // If a query could potentially include documents that violate your security rules, // the query will fail. // on your client app, make sure to include following // .where("author", "==", this.afAuth.auth.currentUser.uid) } function isSignedIn() { // check if user is signed in return request.auth.uid != null; } // SMS App Rules END } } }

AmitXShukla commented 4 years ago

Looks like, I need to fix Firebase rules. Let's do this, change everything to true and that will temporary fix this issue for you. meanwhile I will fix this repository next week.

read: if true write: if true

sreyashi-123 commented 4 years ago

Thanks that really solved the problem.Changed everything to true.Will wait for your rules update next week.

AmitXShukla commented 4 years ago

Thanks for trying, it’s not permanent solution, I’ll debug Firebase rules next week. Looks like there are new breaking changes due to AngularFire 6.0 release and Firebase has changes on rules setup.

sreyashi-123 commented 4 years ago

Any updates on the updated firebase rules?

AmitXShukla commented 4 years ago

Thanks for your patience, I’m working on a similar project and will be uploading a detailed video on how to update your Firebase rules. Please wait for the new videos this week (Part 3 & Part 4) on Firebase rules .

ERP Apps https://www.youtube.com/playlist?list=PLp0TENYyY8lHNMTAlrfVQKzAvQo3yzHYk

https://github.com/AmitXShukla/ERP-Apps-CRM-Cloud-Angular_Firebase

Once I complete this project, I will update this (SMS) repository with New Angular 9 and AngularFire 6.0 and newer Firebase rules.

Amit

sreyashi-123 commented 4 years ago

Thanks for that.Can you also make a demo video on how to make Fb Authentication inclding the steps in Fb developers site and firebase authenication side?I feel i am doing the correct steps but not getting that part correctly displayed in the browser.Also please update your package.json file for latest angular/fire and firebase modules

sreyashi-123 commented 4 years ago

Hello! Any update on the firebase rules for this app.

AmitXShukla commented 4 years ago

updated this repo to latest Angular 9.1.4 version, Please download and re-install this app

AmitXShukla commented 3 years ago

updated this repo to Angular v 11.0.0