File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
packages/core/auth-js/src Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -334,4 +334,39 @@ export default class GoTrueApi {
334334 return { user : null , data : null , error }
335335 }
336336 }
337+
338+ /**
339+ * Generates links to be sent via email or other.
340+ * @param type The link type ("signup" or "magiclink" or "recovery" or "invite").
341+ * @param email the user's email.
342+ * @param password user password for signup only.
343+ * @param data optional user metadata for signup only.
344+ * @param redirectTo The link type ("signup" or "magiclink" or "recovery" or "invite").
345+ */
346+ async generateLink (
347+ type : string ,
348+ email : string ,
349+ options : {
350+ password ?: string
351+ data ?: any
352+ redirectTo ?: string
353+ } = { }
354+ ) : Promise < { data : Session | User | null ; error : Error | null } > {
355+ try {
356+ const data : any = await post (
357+ `${ this . url } /admin/generate_link` ,
358+ {
359+ type,
360+ email,
361+ password : options . password ,
362+ data : options . data ,
363+ redirect_to : options . redirectTo ,
364+ } ,
365+ { headers : this . headers }
366+ )
367+ return { data, error : null }
368+ } catch ( error ) {
369+ return { data : null , error }
370+ }
371+ }
337372}
You can’t perform that action at this time.
0 commit comments