Initial commit
This commit is contained in:
21
pocketbase/pb_hooks/createOtpUser.pb.js
Normal file
21
pocketbase/pb_hooks/createOtpUser.pb.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
onRecordRequestOTPRequest((e) => {
|
||||
// create a user with the OTP email if it doesn't exist
|
||||
|
||||
if (!e.record) {
|
||||
const email = e.requestInfo().body['email']
|
||||
const record = new Record(e.collection)
|
||||
record.setEmail(email)
|
||||
record.setPassword($security.randomString(30))
|
||||
|
||||
const language = e.requestInfo().headers['language'] || 'en'
|
||||
record.set('language', language)
|
||||
|
||||
e.app.save(record)
|
||||
|
||||
e.record = record
|
||||
}
|
||||
|
||||
return e.next()
|
||||
}, 'users')
|
||||
Reference in New Issue
Block a user