-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move user profile update logic to server (fixes #260)
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
- Loading branch information
1 parent
ec9936b
commit bf45873
Showing
10 changed files
with
85 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/server/functions/src/main/kotlin/com/supercilex/robotscouter/server/functions/Init.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.supercilex.robotscouter.server.functions | ||
|
||
import com.supercilex.robotscouter.common.FIRESTORE_LAST_LOGIN | ||
import com.supercilex.robotscouter.common.FIRESTORE_NAME | ||
import com.supercilex.robotscouter.server.utils.FIRESTORE_EMAIL | ||
import com.supercilex.robotscouter.server.utils.FIRESTORE_PHONE_NUMBER | ||
import com.supercilex.robotscouter.server.utils.FIRESTORE_PHOTO_URL | ||
import com.supercilex.robotscouter.server.utils.types.SetOptions | ||
import com.supercilex.robotscouter.server.utils.types.Timestamps | ||
import com.supercilex.robotscouter.server.utils.types.UserInfo | ||
import com.supercilex.robotscouter.server.utils.users | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.asPromise | ||
import kotlinx.coroutines.async | ||
import kotlinx.coroutines.await | ||
import kotlin.js.Date | ||
import kotlin.js.Promise | ||
import kotlin.js.json | ||
|
||
fun initUser(user: UserInfo): Promise<*>? = GlobalScope.async { | ||
console.log("Initializing user: ${JSON.stringify(user.toJSON())}") | ||
|
||
users.doc(user.uid).set(json( | ||
FIRESTORE_LAST_LOGIN to Timestamps.fromDate(Date()), | ||
FIRESTORE_EMAIL to user.email, | ||
FIRESTORE_NAME to user.displayName, | ||
FIRESTORE_PHONE_NUMBER to user.phoneNumber, | ||
FIRESTORE_PHOTO_URL to user.photoURL | ||
), SetOptions.merge).await() | ||
}.asPromise() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
library/core-model/src/main/java/com/supercilex/robotscouter/core/model/User.kt
This file was deleted.
Oops, something went wrong.