@@ -361,7 +361,7 @@ use in any wrapped component.
361
361
362
362
.. glossary::
363
363
364
- ** logIn(credentials)**
364
+ logIn(credentials)
365
365
.. code:: typescript
366
366
:copyable: false
367
367
:caption: Type signature
@@ -504,6 +504,12 @@ use in any wrapped component.
504
504
useEmailPasswordAuth()
505
505
~~~~~~~~~~~~~~~~~~~~~~
506
506
507
+ ``useEmailPasswordAuth`` returns ``result`` and an authentication method you specify, as
508
+ shown below.
509
+
510
+ result
511
+ ``````
512
+
507
513
.. code:: typescript
508
514
:copyable: false
509
515
:caption: Type signature
@@ -516,270 +522,158 @@ use in any wrapped component.
516
522
*Enum values*
517
523
518
524
- ``state``. Can be "not-started", "pending", "success", "error".
519
- - ``operation``. For a list of all operation names, refer to the
520
- :realm-react-sdk:`API documentation <enums/AuthOperationName.html>`.
521
- - ``pending``. Can be ``true`` or ``false``.
522
- - ``success``. Can be ``true`` or ``false``.
523
- - ``error``. Error-based object or undefined.
524
-
525
- logIn(credentials)
526
- ``````````````````
527
-
528
- .. code:: typescript
529
- :copyable: false
530
- :caption: Type signature
531
-
532
- logIn(credentials: { email: string; password: string }): void;
533
-
534
- *Parameters*
535
-
536
- - ``credentials``. An object that contains ``email`` and ``password`` properties.
537
-
538
- *Example*
539
-
540
- Logs a user in using an email and password. You could also call
541
- ``logIn(Realm.Credentials.emailPassword(email, password))``. Returns a
542
- ``Realm.User`` instance of the logged-in user.
543
-
544
- .. code:: typescript
545
-
546
- const {logIn, result} = useEmailPasswordAuth();
547
-
548
- const [email, setEmail] = useState('');
549
- const [password, setPassword] = useState('');
550
-
551
- const performLogin = () => {
552
- logIn({email, password});
553
- };
554
-
555
- if(result.pending) {
556
- return (<LoadingSpinner/>)
557
- }
558
-
559
- if(result.error) {
560
- return (<ErrorComponent/>)
561
- }
562
-
563
- if(result.success) {
564
- return (<SuccessComponent/>)
565
- }
566
- //...
567
-
568
- logOut()
569
- ````````
570
-
571
- .. code:: typescript
572
- :copyable: false
573
- :caption: Type signature
574
-
575
- logOut(): void;
576
-
577
- *Example*
578
-
579
- Logs out the current user.
580
-
581
- .. code:: typescript
582
-
583
- const {logOut, result} = useEmailPasswordAuth();
584
- const performLogout = () => {
585
- logOut();
586
- }
587
525
588
- register(args)
589
- ``````````````
590
-
591
- .. code:: typescript
592
- :copyable: false
593
- :caption: Type signature
594
-
595
- register(args: { email: string; password: string }): void;
596
-
597
- *Parameters*
598
-
599
- - ``args``. An object that contains ``email`` and ``password`` properties.
600
-
601
- *Example*
602
-
603
- Registers a new user. Requires a user email and password.
604
-
605
- .. code:: typescript
606
-
607
- const {register, result} = useEmailPasswordAuth();
608
-
609
- const [email, setEmail] = useState('');
610
- const [password, setPassword] = useState('');
611
-
612
- const performRegister = () => {
613
- register({email, password});
614
- };
615
-
616
- confirm(args)
617
- `````````````
618
-
619
- .. code:: typescript
620
- :copyable: false
621
- :caption: Type signature
622
-
623
- confirm(args: { token: string; tokenId: string }): void;
624
-
625
- *Parameters*
626
-
627
- - ``args``. An object that contains ``token`` and ``tokenId`` properties.
628
-
629
- *Example*
630
-
631
- Confirms a user account. Requires a ``token`` and ``tokenId``.
632
-
633
- .. code:: typescript
634
-
635
- const {confirm, result} = useEmailPasswordAuth();
636
-
637
- const performConfirmation = () => {
638
- confirm({token, tokenId});
639
- };
640
-
641
- resendConfirmationEmail(args)
642
- `````````````````````````````
643
-
644
- .. code:: typescript
645
- :copyable: false
646
- :caption: Type signature
526
+ - ``operation``. For a list of all operation names, refer to the
527
+ :realm-react-sdk:`API documentation <enums/AuthOperationName.html>`.
647
528
648
- resendConfirmationEmail(args: { email: string }): void;
529
+ - ``pending``. Can be ``true`` or ``false``.
649
530
650
- *Parameters*
531
+ - ``success``. Can be ``true`` or ``false``.
651
532
652
- - ``args ``. An object that contains an ``email`` property .
533
+ - ``error ``. Error-based object or undefined .
653
534
654
- *Example*
535
+ Authentication Methods
536
+ `````````````````
655
537
656
- Resends a confirmation email.
538
+ Below is a list of authentication methods and their Type signatures. An example of using
539
+ an authentication method is provided for ``logIn(credentials)``. You use the other authentication
540
+ methods in the same way.
657
541
658
- .. code:: typescript
542
+ .. glossary::
659
543
660
- const {resendConfirmationEmail, result} = useEmailPasswordAuth();
661
- const [email, setEmail] = useState('');
544
+ logIn(credentials)
545
+ .. code:: typescript
546
+ :copyable: false
547
+ :caption: Type signature
662
548
663
- const performResendConfirmationEmail = () => {
664
- resendConfirmationEmail({email});
665
- };
549
+ logIn(credentials: { email: string; password: string }): void;
666
550
667
- retryCustomConfirmation(args)
668
- `````````````````````````````
551
+ *Parameters*
669
552
670
- .. code:: typescript
671
- :copyable: false
672
- :caption: Type signature
553
+ - ``credentials``. An object that contains ``email`` and ``password`` properties.
673
554
674
- retryCustomConfirmation(args: { email: string }): void;
555
+ *Example*
675
556
676
- *Parameters*
557
+ Logs a user in using an email and password. You could also call
558
+ ``logIn(Realm.Credentials.emailPassword(email, password))``. Returns a
559
+ ``Realm.User`` instance of the logged-in user.
677
560
678
- - ``args``. An object that contains an ``email`` property.
561
+ .. code:: typescript
679
562
680
- *Example*
563
+ const {logIn, result} = useEmailPasswordAuth();
681
564
682
- Retries confirmation with a custom function.
565
+ const [email, setEmail] = useState('');
566
+ const [password, setPassword] = useState('');
683
567
684
- .. code:: typescript
568
+ const performLogin = () => {
569
+ logIn({email, password});
570
+ };
685
571
686
- const {retryCustomConfirmation, result} = useEmailPasswordAuth();
687
- const [email, setEmail] = useState('');
572
+ if(result.pending) {
573
+ return (<LoadingSpinner/>)
574
+ }
688
575
689
- const performRetryCustomConfirmation = () => {
690
- retryCustomConfirmation({email});
691
- };
576
+ if(result.error) {
577
+ return (<ErrorComponent/>)
578
+ }
692
579
693
- sendResetPasswordEmail(args)
694
- `````````````````````````````
580
+ if(result.success) {
581
+ return (<SuccessComponent/>)
582
+ }
583
+ //...
695
584
696
- .. code:: typescript
697
- :copyable: false
698
- :caption: Type signature
585
+ logOut()
586
+ .. code:: typescript
587
+ :copyable: false
588
+ :caption: Type signature
699
589
700
- sendResetPasswordEmail(args: { email: string } ): void;
590
+ logOut( ): void;
701
591
702
- *Parameters*
592
+ register(args)
593
+ .. code:: typescript
594
+ :copyable: false
595
+ :caption: Type signature
703
596
704
- - ``args``. An object that contains an `` email`` property.
597
+ register(args: { email: string; password: string }): void;
705
598
706
- *Example *
599
+ *Parameters *
707
600
708
- Sends a password reset email.
601
+ - ``args``. An object that contains `` email`` and ``password`` properties .
709
602
710
- .. code:: typescript
603
+ confirm(args)
604
+ .. code:: typescript
605
+ :copyable: false
606
+ :caption: Type signature
711
607
712
- const {sendResetPasswordEmail, result} = useEmailPasswordAuth();
713
- const [email, setEmail] = useState('');
608
+ confirm(args: { token: string; tokenId: string }): void;
714
609
715
- const performSendResetPasswordEmail = () => {
716
- sendResetPasswordEmail({email});
717
- };
610
+ *Parameters*
718
611
719
- resetPassword(args)
720
- ```````````````````
612
+ - ``args``. An object that contains ``token`` and ``tokenId`` properties.
721
613
722
- .. code:: typescript
723
- :copyable: false
724
- :caption: Type signature
614
+ resendConfirmationEmail(args)
615
+ .. code:: typescript
616
+ :copyable: false
617
+ :caption: Type signature
725
618
726
- resetPassword(args: { token: string; tokenId: string; password : string }): void;
619
+ resendConfirmationEmail(args: { email : string }): void;
727
620
728
- *Parameters*
621
+ *Parameters*
729
622
730
- - ``args``. An object that contains ``token``, ``tokenId``, and ``password``
731
- properties.
623
+ - ``args``. An object that contains an ``email`` property.
732
624
733
- *Example*
625
+ retryCustomConfirmation(args)
626
+ .. code:: typescript
627
+ :copyable: false
628
+ :caption: Type signature
734
629
735
- Resets a user's password.
630
+ retryCustomConfirmation(args: { email: string }): void;
736
631
737
- .. code:: typescript
632
+ *Parameters*
738
633
739
- const {resetPassword, result} = useEmailPasswordAuth();
740
- const [password, setPassword] = useState('');
634
+ - ``args``. An object that contains an ``email`` property.
741
635
742
- const performResetPassword = () => {
743
- resetPassword({token, tokenId, password});
744
- };
636
+ sendResetPasswordEmail(args)
637
+ .. code:: typescript
638
+ :copyable: false
639
+ :caption: Type signature
745
640
746
- callResetPasswordFunction(args, restArgs)
747
- `````````````````````````````````````````
641
+ sendResetPasswordEmail(args: { email: string }): void;
748
642
749
- .. code:: typescript
750
- :copyable: false
751
- :caption: Type signature
643
+ *Parameters*
752
644
753
- callResetPasswordFunction<Args extends unknown[] = []>(
754
- args: {
755
- email: string;
756
- password: string;
757
- },
758
- ...restArgs: Args
759
- ): void;
645
+ - ``args``. An object that contains an ``email`` property.
760
646
761
- *Parameters*
647
+ resetPassword(args)
648
+ .. code:: typescript
649
+ :copyable: false
650
+ :caption: Type signature
762
651
763
- - ``args``. An object that contains ``email`` and ``password`` properties.
764
- - ``restArgs``. Additional arguments that you need to pass to your custom
765
- reset password function.
652
+ resetPassword(args: { token: string; tokenId: string; password: string }): void;
766
653
767
- *Example *
654
+ *Parameters *
768
655
769
- Calls your App Services backend password reset function. Can pass arguments to
770
- the function as needed .
656
+ - ``args``. An object that contains ``token``, ``tokenId``, and ``password``
657
+ properties .
771
658
772
- .. code:: typescript
659
+ callResetPasswordFunction(args, restArgs)
660
+ .. code:: typescript
661
+ :copyable: false
662
+ :caption: Type signature
773
663
774
- const {callResetPasswordFunction, result} = useEmailPasswordAuth();
775
- const [email, setEmail] = useState('');
776
- const [password, setPassword] = useState('');
664
+ callResetPasswordFunction<Args extends unknown[] = []>(
665
+ args: {
666
+ email: string;
667
+ password: string;
668
+ },
669
+ ...restArgs: Args
670
+ ): void;
777
671
778
- const performResetPassword = () => {
779
- callResetPasswordFunction({email, password}, "extraArg1", "extraArg2");
780
- };
672
+ *Parameters*
781
673
782
- .. _react-native-use-app-hook:
674
+ - ``args``. An object that contains ``email`` and ``password`` properties.
675
+ - ``restArgs``. Additional arguments that you need to pass to your custom
676
+ reset password function.
783
677
784
678
useApp()
785
679
~~~~~~~~
0 commit comments