-
Notifications
You must be signed in to change notification settings - Fork 0
feat(user): Add login method using google email #11
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
base: master
Are you sure you want to change the base?
Conversation
ukay, aku coba dulu ya |
if (!isUserExist) { | ||
const userReq: UserRequest = { | ||
email: data.email, | ||
password: 'blueprint123', | ||
} | ||
isUserExist = await this.createUser(userReq) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apakah kalo gini nanti misal kita login tanpa klik login with google (tapi sudah sign up with google dulu) itu asal tahu email dan masukin password blueprint123
langsung bisa masuk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SultanKs4 iya betul, menurutku harusnya ketika signup by google, data baru yang harus disimpan ke schema user ini hanya email saja. Jadi ketika user sudah singup by google dan login menggunakan form, dia gak bakal bisa melakukannya karena passwordnya gak ada. Jadi harus login by google, terus ngeset passwordnya setelah login (fitur ini belum ada, bisa ditambahin nanti)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jadi di user modelnya untuk password requirednya dihapus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
biasanya kan gini kalo kasus aku nyobak di trello gitu,
kalo sign up by email, dia milih emailnya yang mana. terus masukkan password email.
habis itu setelah sign up dia langsung bisa masuk ke trello nya.
terus kalo mau login by google, mekanismenya sama kyk sign up. milih email sama masukin password email.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kalo dia mau login biasa, harusnya masukin username sama password emailnya dia. jdi password ini tetep keisi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SultanKs4 Bukannya udah dipasang sanitizer ya disana?
Jadi kalau mau daftar biasa tetep masukin password
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gopla lupa sanitizer nya wkkw iya bisa sih harus nya
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gopla iyups, jadi kalo waktu sign up by gmail, itu kan dapet email, username, & password gmail. Nah itu di save ke db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@debbysa kayanya untuk password ga dapet deh soalnya kan itu secret banget, aku cari di OAuth 2.0 Scope juga ga ada OAuth 2.0 Scope
Ini aku cuma pindah ke env seperti saran @SultanKs4 Untuk masalah passwordnya masih belum ngeh ._, |
const userToken = jwt.sign( | ||
token as Credentials, | ||
process.env.JWT_SECRET as string | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ini jadinya nanti ada 2 token ya. Satu dari credentials login google, satunya dari email.
Credentials ini otomatis dibuatkan sama googlenya?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iya,
tapi tetep kita pakenya yang token buatan sendiri
Token dari google cuma buat retrieve data dari email kita
const token: any = await jwt.sign( | ||
{ email: isUserExist.email }, | ||
process.env.JWT_SECRET || '' | ||
) | ||
resolve(token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aku masih bingung baris ini sih.
di fungsi authenticateUser() sebelumnya, aku sudah buat jwt.sign.
Disini kenapa dikasih jwt.sign lagi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Karena di fungsi authenticateUser() kan ada cek passwordnya
Sedangkan kalau login by google kita ga perlu masukin password
Jadi aku buat jwt.sign lagi disini
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gopla jadi ini jwt sign nya beda lagi sama yang sebelumnya ya? yang token as credentials
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@debbysa iya, beda. karena token as credentials yang atas itu bener udah contain data kita tapi masih dalam bentuk enkripsi
Ini kalau mau cek diclone dulu ya,
Soalnya link callback di googlenya cuma aku set di local sama production
nanti di file gOauth.ts balik url local ke index ke-0
Untuk testing google oauthnya sendiri aku belum nemu gimana caranya :''