stuck on loading screen - flutter

this is the problem
enter image description here
I use firebase to store the data
this is my code :
Homepage.dart
main.dart
I already follow all the step but still get the error.
I expect this. I don't know how to explain what i expecting but I have the picture that's what I want. I hope you can help me guys
enter image description here

You don't have permission to access the data from firestore, maybe you have set up the firestore in production mode when creating. To set this in test mode you can add this to your security rules.
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
This will make your firestore database accessible to anyone, this means anyone can read or write to your database.
Also, create a view for the error page, so you don't have to stick to the loading screen. You can make it by adding an additional else statement.

Related

Get Firebase Dynamic Link Data from String Input url Flutter

Dynamic links work great for 98% of our users. However, there are still a group of users which have difficulty with them or do not know how to use them.
I want to add a feature which would let users paste their link into the app, and then we extract the data from the link and handle it normally. This will also serve as a backup for when the links are down or misbehaving. It will also allow our customer service team to get data from a link when customers share them with us.
The problem is, there doesn't seem to be a way to manually pass in a dynamic link to retrieve the dynamic data.
Does anyone know how this can be achieved?
Here is my attempt at your question.
I am assuming what you mean by the dynamic data is the underlying deeplink along with the parameters associated with the deeplink.
void dynamicLinkToDeepLink(String dynamicLinkString) async {
final details = await FirebaseDynamicLinks.instance.getDynamicLink(Uri.parse(dynamicLinkString));
// your deep link can be accessed as follows
details!.link;
}
You have to safeguard the above code as you see fits when you use it. You will have to wrap FirebaseDynamicLinks.instance..... with a try catch block and you will also have to check if the value of the returned link is not null before acccessing details!.link

Firebase Storage: Public to Internet about files under a specific directory

I want to publish all the files under a specific directory to the Internet.
Security Rules
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /public/{allPaths=**} {
allow read;
allow write: if request.auth != null;
}
}
}
After writing the security rules as described above, when I open the Browser of Cloud Storage:
The files under the directory are still set to private.
If you look at the details of each file, you will see that no public URL has been issued.
And when I enter the Authenticated URL, you will be redirected to Google's login page.
How can I fix this?
Firebase security rules only control who can get the URL of a specific object either by Firebase SDK or REST APIs. If you check for object URL in Firebase console, you'll see an URL of format which is probably what you are looking for:
https://firebasestorage.googleapis.com/v0/b/[PROJECT].appspot.com/o/public%2Fdog.jpg?alt=media&token=fd991fdf-a33f-4321-9017-09907e1a5243
Security rules can only restrict users from getting this URL at first place however anyone with this URL can access the image/file (if an authorized user has shared the URL).
That being said, the rule allow read: if true; will allow anyone to get the public (like the one shown above) and they can access it.
If you want a public link from GCS as well then you would have to edit permissions from GCP console and allow allUsers to read it:

Firebase Storage Code -13000 Permission Error

I have previously been able to use firebase to store user images, but when once I created a new xcode project I've been getting this error:
Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please
check the server response." UserInfo={object=WtLirPvwL9b7eI3zipGZkk1G4Hi2,
ResponseBody={
"error": {
"code": 400,
"message": "Permission denied. Please enable Firebase Storage for your bucket by
visiting the Storage tab in the Firebase Console and ensure that you have
sufficient permission to properly provision resources."
}
I have been getting this error even after setting up storage for my project.
And I don't think it has to do with the usage rules--for one, I allowed unauthorized reads and writes, and in my testing, the user is already authorized before attempting to push images to storage. In fact, the uid generated from firebase's auth is what is being used as the reference. Also noteworthy is the fact that authorization with firebase is working fine--I'm having no errors creating accounts.
Another interesting fact--I also received this error after setting up yet another XCode project (and the corresponding steps in Firebase). So with two different Xcode projects, the same error is happening to me.
EDIT: usage rules and permissions
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
This is the default usage configuration. I previously had changed the content to allow read allow write to see if that would affect anything. But my error is happening with both that config and the default one.
Also, someone linked in the comments to a site recommending to check IAM and Admin permissions. As I suspected, I am the owner and so I see no permission problem there.
Additionally, nothing appears to be wrong with the GoogleService-Info.plist, even though that was what I suspected was wrong. Indeed, it includes the correct string for my storage bucket.
EDIT 2: CONSOLE ERROR
Thanks for #Leopold for pointing out that this error also occurs in the console. At first I thought that the console was working for me (I was able to upload images to it) but I now get the error when trying to view the image I uploaded through the console.
I got to this page by clicking on the image name hyperlink.
For me it looks, that Google Cloud Platform configured in the way, that you do not have permission storage bucket.
Go to https://console.cloud.google.com
Pick your project
Navigate to Cloud Storage
Go to Permissions tab
Add permission. Add permission which suits your needs most.
For my storage I am allowing to access my storage for everyone. And for you to see and play for troubleshooting to do the same.
In the permission tap ADD
Add Storage Object Viewer
Click save
Considering I don't find older questions about this Exact issue, and that the only ones are from yesterday, then I suspect it's a server/google side issue. So I went on firebase storage, uploaded a file through the console, and then I saw this on the right side, under the upload button:
Error Loading Thumbnail/Image (Erro Carregando Visualiação)
image
And then I clicked on the name link (Nome: Fachada.jpg)
and got this:
Permission denied. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources.
{ "error": {
"code": 400,
"message": "Permission denied. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and
ensure that you have sufficient permission to properly provision
resources." } }
So even the console is yielding this error! It's server sided, you just have to wait, and I have never seen this happen before on Firebase(there is no google search result for this exact error, except for yesterday Saturday, November 20th 2021)

keycloak: notification after max login failure

After a user has failed to log in too many times in too short a time, is there a way to have the Keycloak login screen tell the user that they are temporarily locked, so they can know they have to wait and try again later?
At the moment, it continues to tell them their password is wrong, so they will probably keep trying, and may end up being told their correct password is incorrect.
Keycloak provides you the possibility to define custom messages and to provide a custom theme where you can overwrite certain views and messages as well as provide messages for other languages.
https://www.keycloak.org/docs/latest/server_development/#_themes
Custom message key
You can modify the message key 'invalidUserMessage' which is the message shown when the user is locked. It defaults to 'Invalid username or password'.
We do it by providing a custom theme for the login type, but you can modify the message key provided by the keycloak installation at 'keycloak/themes/base/login/messages/messages_en.properties'.
Custom view
When you provide a custom login-password.ftl or login.ftl, depends on what you use, then you could check for the message during the rendering, and conditionally render a part which is only shown when the user is locked.
<#assign userLocked = message?? && message.summary == msg("invalidUserMessage")>
<#if section = "header" && !userLocked >...<#/if>
For instance, we use it in javascript to disable all inputs when we see that the user is locked along with displaying the modified message to the user.
<script>
const serverFieldErrors = {
"password": "${(message.summary)!""}"
}
if (serverFieldErrors.password === "${msg('invalidUserMessage')}") {
document.querySelectorAll("input").forEach((element) => element.setAttribute("disabled", "disabled"));
}
</script>
To my knowledge, keycloak provides no other way to handle such a use case.

How to atomically delete user and user's data from Firebase Auth and Realtime Database respectively?

Some background
When a user account is created, I do 3 things using callback chaining in the sequence 1 > 2 > 3.
A user is created in Firebase Auth (the standard way using createUser(withEmail ...))
I upload the user's profile picture to Firebase Storage and capture the returned downloadUrl for use in step 3
I store the user's other information (including the downloadUrl from step 2) in a node in the realtime database (keyed by $userid)
Now the problem
I provide a button called 'Delete account' which should enable the user to delete everything. That is, clear all their data in the Realtime Database, clear their profile picture in Firebase Storage, and finally delete their account from Auth. The important thing is that all these operations should succeed or be canceled if even one fails.
I've gone through ~10 pages of S/O questions & answers, there was 1 unanswered question like this one (it asked about the account creation process...I suppose an answer to that question can easily be adapted here.)
What have i tried?
Currently, I use callback chaining like so:
// start by atomically deleting all the user data from the Realtime Database using the fanout system.
- get all appropriate locations and save in fanout dictionary
- update all these locations to nil // atomic goodness :)
-callback:
-on failure:
- just return // no worries, nothing has changed yet :/
-on success:
// proceed to delete user files on firebase storage
- delete path $userid on firebase storage
-callback:
-on failure: // this is bad, no idea what to do :(
-on success:
// proceed to delete account from Auth
- delete user account from Auth
-callback:
-on failure: // this is terrible, also, it could happen often b/c firebase does ask for re-authentication sometimes :(
-on success: // thank goodness! I have an authListener somewhere ready to show the 'signInViewController' :)
How do you handle such multi-system (Auth, Storage, RealtimeDB) operation atomically? I have looked into transactions but can't see how they can be adapted for this - the docs only show them being used in incrementing counters for likes/stars etc in the RealtimeDB.
Any help will be very much appreciated.
So the main problem is what to do if the data you're trying to delete is being deleted only partially.
I think you should think about a method that will help you restore it if something goes wrong.
I'm not on my computer now but I suggest you to try to download the data that you want to delete and only if there were a success you delete the local copy too, otherwise you should be able to restore it easily.
Edit: if we talk about a serious amount of storage instead of a local copy you can make it on the cloud.
So you first copy this data, then delete it, then delete the database data (also copied previously) then you can delete the user account and finally you can delete the copy.