You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Get the uid of the user newly created and adds to the document referring to the user, this step is very important so that the trigger used to delete the user works
27
+
//Get the uid of the user newly created and adds to the document
28
+
//referring to the user, this step is very important so that the
//get user token to verify that the user is actually logged in
69
71
constuserToken=req.get('userToken');
70
-
//verify the token and returns DecodedIdToken as decoded, containing the list properties here https://firebase.google.com/docs/reference/admin/node/admin.auth.DecodedIdToken
72
+
//verify the token and returns DecodedIdToken as decoded, containing the
//get user token to verify that the user is actually logged in
106
114
constuserToken=req.get('userToken');
107
-
//verify the token and returns DecodedIdToken as decoded, containing the list properties here https://firebase.google.com/docs/reference/admin/node/admin.auth.DecodedIdToken
115
+
//verify the token and returns DecodedIdToken as decoded, containing the
//revoke login token for desconect a conected user
112
122
admin.auth().revokeRefreshTokens(uid)
113
123
.then(()=>{
114
-
//delete user using uid received by a post request and attributed to "let uid = req.body.uid", you can see more on http://expressjs.com/en/4x/api.html#req.body
124
+
//delete user using uid received by a post request and
125
+
//attributed to "let uid = req.body.uid", you can see
126
+
//more on http://expressjs.com/en/4x/api.html#req.body
115
127
admin.auth().deleteUser(uid)
116
128
.then(()=>{
117
129
console.log("Deleted user successfully");
118
-
//send a message to client web if the user is successfully deleted
130
+
//send a message to client web if the user is
131
+
//successfully deleted
119
132
res.status(200).send({
120
133
code: 1,
121
134
message: 'Deleted user successfully'
122
135
});
123
136
})
124
137
.catch((error)=>{
125
138
console.log("There was an error deleting the user",error);
126
-
//send a message to client web if occurred an error on user delete
//get user token to verify that the user is actually logged in
143
157
constuserToken=req.get('userToken');
144
-
//verify the token and returns DecodedIdToken as decoded, containing the list properties here https://firebase.google.com/docs/reference/admin/node/admin.auth.DecodedIdToken
158
+
//verify the token and returns DecodedIdToken as decoded, containing the
//list all users and return listUsersResult, you can see complete properties here https://firebase.google.com/docs/reference/admin/node/admin.auth.ListUsersResult
163
+
//list all users and return listUsersResult, you can see
//in this part we assign the "users" property of the listUsersResult to the variable users, you can see more of users properties here https://firebase.google.com/docs/reference/admin/node/admin.auth.UserRecord
167
+
//in this part we assign the "users" property of the
168
+
//listUsersResult to the variable users, you can see more of
//as i had used an "if" to exclude the admin user from the listing, the "objUser" array would return with one of its positions as null, to solve this we used the filter function
186
+
//as i had used an "if" to exclude the admin user from the
187
+
//listing, the "objUser" array would return with one of its
188
+
//positions as null, to solve this we used the filter
189
+
//function
165
190
res.status(200).send(objUsers.filter(Boolean));
166
191
});
167
-
})
168
-
.catch((err)=>res.status(401).send(err));//send a message to client web if the user token is invalid
192
+
})//send a message to client web if the user token is invalid
0 commit comments