Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After that an user upload the data , how to retrieve the uid or phone number of the user who upload and uid or phone number of other users who is in upload data of this user . #23

Closed
russellmoya opened this issue Apr 19, 2020 · 11 comments

Comments

@russellmoya
Copy link

No description provided.

@esQmo
Copy link

esQmo commented Apr 19, 2020

Can you please use a valid title and explain your issue in the "description" section?

@russellmoya
Copy link
Author

ok

@russellmoya
Copy link
Author

how to know the phone number or the uid of the users in this data uploaded

@esQmo
Copy link

esQmo commented Apr 19, 2020

How did you manage to get the upload PIN? @russellmoya

@rinekri
Copy link

rinekri commented Apr 19, 2020

@russellmoya you can download uploaded file by ObjectMetadata and decode msg (where contains encoded contacted user id) from the records list and token (where contains encoded user id who uploaded data). But your token is empty and it seems you are avoided getToken process.

@russellmoya
Copy link
Author

Thanks a lot @rinekri for answer me.
i remove the token , but in the original code , i have the token . @rinekri .
i have Encryption secret key , that i store in google cloud secret manager .
but i want know how to decode msg and token

@russellmoya you can download uploaded file by ObjectMetadata and decode msg (where contains encoded contacted user id) from the records list and token (where contains encoded user id who uploaded data). But your token is empty and it seems you are avoided getToken process.

@rinekri
Copy link

rinekri commented Apr 19, 2020

@russellmoya you can use decryptTempID and validateToken functions to do this. You can find them in the existing files: first / second. For encryptionKey parameter use await getEncryptionKey()

@russellmoya
Copy link
Author

russellmoya commented Apr 19, 2020

How did you manage to get the upload PIN? @russellmoya

i modify getUploadToken.ts file .
in the getUploadToken.ts , i change if (data) code .
the new code :

if (data) {
//const uploadCodes = await retrieveUploadCodes();
const uploadCodes = uid.substring(0, 6).toUpperCase();
console.log('getUploadToken:', obtained ${uploadCodes.length} upload codes);
console.log("voici le code de retrive",uploadCodes);

if(uploadCodes.length >0){
    if(uploadCodes === data.toUpperCase()){
      valid = true ;
    } else {
        valid = false ;
    }
}

// valid = uploadCodes.find(x => x === data) !== undefined;
console.log('getUploadToken:', data is ${valid ? 'valid' : 'not valid'} code);
}

@russellmoya
Copy link
Author

@russellmoya you can use decryptTempID and validateToken functions to do this. You can find them in the existing files: first / second. For encryptionKey parameter use await getEncryptionKey()

for msg i use descyptTempID and for token i use validateToken ? ... @rinekri

@rinekri
Copy link

rinekri commented Apr 19, 2020

@rinekri yeah. This is an example how you can download uploaded data to decrypt it:

async function getCurrentUploadedData(event: ObjectMetadata): Promise<UploadedData> {
  return admin.storage().bucket(event.bucket).file(event.name!).download().then(file => {
    const uploadedData = JSON.parse(file[0].toString())
    console.log('getUploadedData:', `Uploaded data token: ${uploadedData.token}`);
    return uploadedData
  }).catch(function (error) {
    console.log("getUploadedData", error);
    return null
  })
}

interface UploadedData {
  records: Record[];
  token: string
}

interface Record {
  id: string,
  msg: string,
  timestamp: string
}

@russellmoya
Copy link
Author

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants