How to get data from custom UID in firebase? - java

I have data structure like this for my android app. That can login and only see their profile. I dont make add content or do saving data to the database. So i created the data manually and the users only read and display the data.
How to make login,refer with username = "71140011" and password = "123456" which is inside real time database and the 71140011 only can see their profile only. thanks

Related

How to structure a Firebase Realtime-Database?

I am trying to set up a Google Firebase Realtime Database to store user data. I am really new to Java and Firebase and until now user data gets saved just under the Uid. I now want to have different categories like Users, Posts, Messages... How can I add such a structure to my Database? I will link a Screenshot of my Database.
I am completely new to those things​ and don't even know in which file I can add such a structure.
You can structure your database something like this :
Users :
Users -> uid(With users information.)
Posts
Posts -> user_id -> post_id(with post details)
Messages :
Message -> user_id -> messages (with message and receiver id.)

contacting mysql server database from android java

Hi i have my own hosting and i have created a database there in which i have two columns
host = "mysql.hostinger.in"
database = "mydatabase"
username = "myuser"
pass = "123"
TABLE = "Data"
'email' = column (TEXT)
'eligible' = column (INT)
now what i want to do is i need to contact my database to check if the email suppose "abc#xyz.com" is eligible ie. "1" means YES and "0" means NO
so how i connect to my database from android java any code snippet ?
also is this require to put password for database to contact ?
what if anybody decompile my application and get username and password then he can interfere which i do not want
do not want to put my sqldatabase password to fetch the data how could i do that ,someone said i need webservice to do that i am not good with php
If you have your own hosting, you could make little Rest, making and putting up PHP script on your server that returns for example JSON and get it in your App using JSON parser (f. ex. Volley Library). Your PHP file would hold all database connections etc

Is this possible to add custom query in Kibana dashboard which is hidden from logged in user?

Is this possible to add custom query in Kibana dashboard which is hidden from logged in user. For example, I have index which have data of multiple users i want user can see only own data. For that i have user_id in each document which are stored in Elasticsearch.
Actually, I want when user log in, add a hidden field which is user_id and when he creating query for dashboard a custom query automatically add in query which is generated by Kibana.Is this possible ? Or something similar?

get mongodb file id before the image is saved using gridfs

I a new to MongoDb GridFs. I am making an application where I am creating a meeting and uploading files related to the meeting. When I save the entire record, the table must have the meeting id auto generated number and the document id that I receive from the mongodb
return gridFsTemplate.store(inputStream, documentName, "image/jpeg", metaData).getId();
Now, the business require that the file is uploaded asynchronously so that the big file does not hold the page and the user does not have to wait for the upload to complete to submit the page. The problem is, I will not get the document id unless the entire upload is done. But unless I have the id, i cannot save the data with meeting id in the mysql table.
Please suggest an alternative.
replace your code to:-
return (ObjectId)gridFsTemplate.store(inputStream, documentName, "image/jpeg", metaData).getId();

Why isn't the database being updated when I refresh the entity manager?

I'm currently developing a social networking site and I'm currently implementing the part where a user can change his password. I'm using the entity manager to refresh the contents of the database with the new password. The following is the code for the implementation.
final Implementation user = em.find(Implementation.class, username);
if((user!=null) && user.getPassword().equals(hash(username,oldPassword))){
user.setPassword(hash(username,newPassword));
em.refresh(user);
}else{
throw new ChangePasswordException();
}
however when I try to login again, the older password must be used, otherwise, if the new password is supplied it will tell you: passwords do not match. Does anyone know maybe why this is happening? I tried to first remove the user from the database, and then persist the new user again. However an EJB Exception was generated as the username was not unique since the user was not removed from the database.
Thanks a lot for your help
You are not saving your new password. You are overwriting your changes you have made. So refresh(user) will fetch the current state of that user and will write it into your object.
docu: Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
Try to use merge or persist instead

Categories