@pisell/pisellos 0.0.336 → 0.0.337
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solution/RegisterAndLogin/config.d.ts +1 -0
- package/dist/solution/RegisterAndLogin/config.js +23 -1
- package/dist/solution/RegisterAndLogin/index.d.ts +4 -0
- package/dist/solution/RegisterAndLogin/index.js +580 -507
- package/dist/solution/RegisterAndLogin/types.d.ts +1 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +1 -0
- package/lib/solution/RegisterAndLogin/config.js +19 -1
- package/lib/solution/RegisterAndLogin/index.d.ts +4 -0
- package/lib/solution/RegisterAndLogin/index.js +79 -28
- package/lib/solution/RegisterAndLogin/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
65
65
|
error = '没有找到邮箱注册链接的 code,请先调用 sendEmailRegisterLink';
|
|
66
66
|
this.store.error = error;
|
|
67
67
|
return _context.abrupt("return", {
|
|
68
|
-
|
|
68
|
+
status: false,
|
|
69
69
|
message: error
|
|
70
70
|
});
|
|
71
71
|
case 5:
|
|
@@ -77,7 +77,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
77
77
|
});
|
|
78
78
|
case 9:
|
|
79
79
|
response = _context.sent;
|
|
80
|
-
if (!response.
|
|
80
|
+
if (!response.status) {
|
|
81
81
|
_context.next = 15;
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
@@ -148,7 +148,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
148
|
return this.apiCaller.call('emailCodeRegister', params);
|
|
149
149
|
case 7:
|
|
150
150
|
response = _context2.sent;
|
|
151
|
-
if (!(response.
|
|
151
|
+
if (!(response.status && response.data)) {
|
|
152
152
|
_context2.next = 15;
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
@@ -226,7 +226,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
226
226
|
return this.apiCaller.call('phoneCodeRegister', params);
|
|
227
227
|
case 7:
|
|
228
228
|
response = _context3.sent;
|
|
229
|
-
if (!(response.
|
|
229
|
+
if (!(response.status && response.data)) {
|
|
230
230
|
_context3.next = 15;
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
@@ -402,7 +402,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
402
402
|
return this.apiCaller.call('validateToken', token);
|
|
403
403
|
case 3:
|
|
404
404
|
response = _context6.sent;
|
|
405
|
-
if (!(response.
|
|
405
|
+
if (!(response.status && response.data)) {
|
|
406
406
|
_context6.next = 9;
|
|
407
407
|
break;
|
|
408
408
|
}
|
|
@@ -463,7 +463,7 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
463
463
|
return this.apiCaller.call('sendEmailVerificationCode', params);
|
|
464
464
|
case 5:
|
|
465
465
|
response = _context7.sent;
|
|
466
|
-
if (!response.
|
|
466
|
+
if (!response.status) {
|
|
467
467
|
_context7.next = 13;
|
|
468
468
|
break;
|
|
469
469
|
}
|
|
@@ -518,13 +518,13 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
518
518
|
return sendEmailVerificationCode;
|
|
519
519
|
}()
|
|
520
520
|
/**
|
|
521
|
-
*
|
|
521
|
+
* 发送邮箱登录验证码
|
|
522
522
|
*/
|
|
523
523
|
)
|
|
524
524
|
}, {
|
|
525
|
-
key: "
|
|
525
|
+
key: "sendEmailLoginCode",
|
|
526
526
|
value: (function () {
|
|
527
|
-
var
|
|
527
|
+
var _sendEmailLoginCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
528
528
|
var response, now;
|
|
529
529
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
530
530
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -533,33 +533,33 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
533
533
|
this.store.isLoading = true;
|
|
534
534
|
this.store.error = null;
|
|
535
535
|
_context8.next = 5;
|
|
536
|
-
return this.apiCaller.call('
|
|
536
|
+
return this.apiCaller.call('sendEmailLoginCode', params);
|
|
537
537
|
case 5:
|
|
538
538
|
response = _context8.sent;
|
|
539
|
-
if (!response.
|
|
539
|
+
if (!response.status) {
|
|
540
540
|
_context8.next = 13;
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
543
543
|
// 记录验证码发送状态
|
|
544
544
|
now = Date.now();
|
|
545
|
-
this.store.verificationCodeSent[params.
|
|
545
|
+
this.store.verificationCodeSent[params.target] = {
|
|
546
546
|
sent: true,
|
|
547
547
|
sentAt: now,
|
|
548
548
|
expiresAt: now + 5 * 60 * 1000 // 5分钟过期
|
|
549
549
|
};
|
|
550
550
|
_context8.next = 11;
|
|
551
|
-
return this.core.effects.emit(RegisterAndLoginHooks.
|
|
552
|
-
target: params.
|
|
553
|
-
purpose:
|
|
551
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationSent, {
|
|
552
|
+
target: params.target,
|
|
553
|
+
purpose: params.purpose
|
|
554
554
|
});
|
|
555
555
|
case 11:
|
|
556
556
|
_context8.next = 16;
|
|
557
557
|
break;
|
|
558
558
|
case 13:
|
|
559
|
-
this.store.error = response.message || '
|
|
559
|
+
this.store.error = response.message || '发送验证码失败';
|
|
560
560
|
_context8.next = 16;
|
|
561
|
-
return this.core.effects.emit(RegisterAndLoginHooks.
|
|
562
|
-
target: params.
|
|
561
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
562
|
+
target: params.target,
|
|
563
563
|
error: this.store.error
|
|
564
564
|
});
|
|
565
565
|
case 16:
|
|
@@ -567,10 +567,10 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
567
567
|
case 19:
|
|
568
568
|
_context8.prev = 19;
|
|
569
569
|
_context8.t0 = _context8["catch"](0);
|
|
570
|
-
this.store.error = '
|
|
570
|
+
this.store.error = '发送验证码失败';
|
|
571
571
|
_context8.next = 24;
|
|
572
|
-
return this.core.effects.emit(RegisterAndLoginHooks.
|
|
573
|
-
target: params.
|
|
572
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
573
|
+
target: params.target,
|
|
574
574
|
error: this.store.error
|
|
575
575
|
});
|
|
576
576
|
case 24:
|
|
@@ -585,7 +585,80 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
585
585
|
}
|
|
586
586
|
}, _callee8, this, [[0, 19, 25, 28]]);
|
|
587
587
|
}));
|
|
588
|
-
function
|
|
588
|
+
function sendEmailLoginCode(_x7) {
|
|
589
|
+
return _sendEmailLoginCode.apply(this, arguments);
|
|
590
|
+
}
|
|
591
|
+
return sendEmailLoginCode;
|
|
592
|
+
}()
|
|
593
|
+
/**
|
|
594
|
+
* 发送手机号注册验证码
|
|
595
|
+
*/
|
|
596
|
+
)
|
|
597
|
+
}, {
|
|
598
|
+
key: "sendSmsRegisterCode",
|
|
599
|
+
value: (function () {
|
|
600
|
+
var _sendSmsRegisterCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
601
|
+
var response, now;
|
|
602
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
603
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
604
|
+
case 0:
|
|
605
|
+
_context9.prev = 0;
|
|
606
|
+
this.store.isLoading = true;
|
|
607
|
+
this.store.error = null;
|
|
608
|
+
_context9.next = 5;
|
|
609
|
+
return this.apiCaller.call('sendSmsRegisterCode', params);
|
|
610
|
+
case 5:
|
|
611
|
+
response = _context9.sent;
|
|
612
|
+
if (!response.status) {
|
|
613
|
+
_context9.next = 13;
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
// 记录验证码发送状态
|
|
617
|
+
now = Date.now();
|
|
618
|
+
this.store.verificationCodeSent[params.phone] = {
|
|
619
|
+
sent: true,
|
|
620
|
+
sentAt: now,
|
|
621
|
+
expiresAt: now + 5 * 60 * 1000 // 5分钟过期
|
|
622
|
+
};
|
|
623
|
+
_context9.next = 11;
|
|
624
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationSent, {
|
|
625
|
+
target: params.phone,
|
|
626
|
+
purpose: VerificationPurpose.REGISTER
|
|
627
|
+
});
|
|
628
|
+
case 11:
|
|
629
|
+
_context9.next = 16;
|
|
630
|
+
break;
|
|
631
|
+
case 13:
|
|
632
|
+
this.store.error = response.message || '发送注册验证码失败';
|
|
633
|
+
_context9.next = 16;
|
|
634
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
635
|
+
target: params.phone,
|
|
636
|
+
error: this.store.error
|
|
637
|
+
});
|
|
638
|
+
case 16:
|
|
639
|
+
return _context9.abrupt("return", response);
|
|
640
|
+
case 19:
|
|
641
|
+
_context9.prev = 19;
|
|
642
|
+
_context9.t0 = _context9["catch"](0);
|
|
643
|
+
this.store.error = '发送注册验证码失败';
|
|
644
|
+
_context9.next = 24;
|
|
645
|
+
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
646
|
+
target: params.phone,
|
|
647
|
+
error: this.store.error
|
|
648
|
+
});
|
|
649
|
+
case 24:
|
|
650
|
+
return _context9.abrupt("return", _context9.t0);
|
|
651
|
+
case 25:
|
|
652
|
+
_context9.prev = 25;
|
|
653
|
+
this.store.isLoading = false;
|
|
654
|
+
return _context9.finish(25);
|
|
655
|
+
case 28:
|
|
656
|
+
case "end":
|
|
657
|
+
return _context9.stop();
|
|
658
|
+
}
|
|
659
|
+
}, _callee9, this, [[0, 19, 25, 28]]);
|
|
660
|
+
}));
|
|
661
|
+
function sendSmsRegisterCode(_x8) {
|
|
589
662
|
return _sendSmsRegisterCode.apply(this, arguments);
|
|
590
663
|
}
|
|
591
664
|
return sendSmsRegisterCode;
|
|
@@ -597,20 +670,20 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
597
670
|
}, {
|
|
598
671
|
key: "sendEmailRegisterLink",
|
|
599
672
|
value: (function () {
|
|
600
|
-
var _sendEmailRegisterLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
673
|
+
var _sendEmailRegisterLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(email) {
|
|
601
674
|
var response, _response$data3, now;
|
|
602
|
-
return _regeneratorRuntime().wrap(function
|
|
603
|
-
while (1) switch (
|
|
675
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
676
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
604
677
|
case 0:
|
|
605
|
-
|
|
678
|
+
_context10.prev = 0;
|
|
606
679
|
this.store.isLoading = true;
|
|
607
680
|
this.store.error = null;
|
|
608
|
-
|
|
681
|
+
_context10.next = 5;
|
|
609
682
|
return this.apiCaller.call('sendEmailRegisterLink', email);
|
|
610
683
|
case 5:
|
|
611
|
-
response =
|
|
612
|
-
if (!response.
|
|
613
|
-
|
|
684
|
+
response = _context10.sent;
|
|
685
|
+
if (!response.status) {
|
|
686
|
+
_context10.next = 14;
|
|
614
687
|
break;
|
|
615
688
|
}
|
|
616
689
|
// 保存返回的 code
|
|
@@ -625,45 +698,45 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
625
698
|
sentAt: now,
|
|
626
699
|
expiresAt: now + 24 * 60 * 60 * 1000 // 24小时过期
|
|
627
700
|
};
|
|
628
|
-
|
|
701
|
+
_context10.next = 12;
|
|
629
702
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationSent, {
|
|
630
703
|
target: email,
|
|
631
704
|
purpose: VerificationPurpose.REGISTER
|
|
632
705
|
});
|
|
633
706
|
case 12:
|
|
634
|
-
|
|
707
|
+
_context10.next = 17;
|
|
635
708
|
break;
|
|
636
709
|
case 14:
|
|
637
710
|
this.store.error = response.message || '发送注册邀请链接失败';
|
|
638
|
-
|
|
711
|
+
_context10.next = 17;
|
|
639
712
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
640
713
|
target: email,
|
|
641
714
|
error: this.store.error
|
|
642
715
|
});
|
|
643
716
|
case 17:
|
|
644
|
-
return
|
|
717
|
+
return _context10.abrupt("return", response);
|
|
645
718
|
case 20:
|
|
646
|
-
|
|
647
|
-
|
|
719
|
+
_context10.prev = 20;
|
|
720
|
+
_context10.t0 = _context10["catch"](0);
|
|
648
721
|
this.store.error = '发送注册邀请链接失败';
|
|
649
|
-
|
|
722
|
+
_context10.next = 25;
|
|
650
723
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
651
724
|
target: email,
|
|
652
725
|
error: this.store.error
|
|
653
726
|
});
|
|
654
727
|
case 25:
|
|
655
|
-
return
|
|
728
|
+
return _context10.abrupt("return", _context10.t0);
|
|
656
729
|
case 26:
|
|
657
|
-
|
|
730
|
+
_context10.prev = 26;
|
|
658
731
|
this.store.isLoading = false;
|
|
659
|
-
return
|
|
732
|
+
return _context10.finish(26);
|
|
660
733
|
case 29:
|
|
661
734
|
case "end":
|
|
662
|
-
return
|
|
735
|
+
return _context10.stop();
|
|
663
736
|
}
|
|
664
|
-
},
|
|
737
|
+
}, _callee10, this, [[0, 20, 26, 29]]);
|
|
665
738
|
}));
|
|
666
|
-
function sendEmailRegisterLink(
|
|
739
|
+
function sendEmailRegisterLink(_x9) {
|
|
667
740
|
return _sendEmailRegisterLink.apply(this, arguments);
|
|
668
741
|
}
|
|
669
742
|
return sendEmailRegisterLink;
|
|
@@ -675,61 +748,61 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
675
748
|
}, {
|
|
676
749
|
key: "verifyEmailRegistrationLink",
|
|
677
750
|
value: (function () {
|
|
678
|
-
var _verifyEmailRegistrationLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
751
|
+
var _verifyEmailRegistrationLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
679
752
|
var response;
|
|
680
|
-
return _regeneratorRuntime().wrap(function
|
|
681
|
-
while (1) switch (
|
|
753
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
754
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
682
755
|
case 0:
|
|
683
|
-
|
|
756
|
+
_context11.prev = 0;
|
|
684
757
|
this.store.isLoading = true;
|
|
685
758
|
this.store.error = null;
|
|
686
|
-
|
|
759
|
+
_context11.next = 5;
|
|
687
760
|
return this.apiCaller.call('verifyEmailRegistrationLink', params);
|
|
688
761
|
case 5:
|
|
689
|
-
response =
|
|
690
|
-
if (!response.
|
|
691
|
-
|
|
762
|
+
response = _context11.sent;
|
|
763
|
+
if (!response.status) {
|
|
764
|
+
_context11.next = 11;
|
|
692
765
|
break;
|
|
693
766
|
}
|
|
694
|
-
|
|
767
|
+
_context11.next = 9;
|
|
695
768
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationVerified, {
|
|
696
769
|
target: 'email-registration-link',
|
|
697
770
|
purpose: VerificationPurpose.REGISTER
|
|
698
771
|
});
|
|
699
772
|
case 9:
|
|
700
|
-
|
|
773
|
+
_context11.next = 14;
|
|
701
774
|
break;
|
|
702
775
|
case 11:
|
|
703
776
|
this.store.error = response.message || '邮箱注册链接验证失败';
|
|
704
|
-
|
|
777
|
+
_context11.next = 14;
|
|
705
778
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
706
779
|
target: 'email-registration-link',
|
|
707
780
|
error: this.store.error
|
|
708
781
|
});
|
|
709
782
|
case 14:
|
|
710
|
-
return
|
|
783
|
+
return _context11.abrupt("return", response);
|
|
711
784
|
case 17:
|
|
712
|
-
|
|
713
|
-
|
|
785
|
+
_context11.prev = 17;
|
|
786
|
+
_context11.t0 = _context11["catch"](0);
|
|
714
787
|
this.store.error = '邮箱注册链接验证失败';
|
|
715
|
-
|
|
788
|
+
_context11.next = 22;
|
|
716
789
|
return this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
717
790
|
target: 'email-registration-link',
|
|
718
791
|
error: this.store.error
|
|
719
792
|
});
|
|
720
793
|
case 22:
|
|
721
|
-
return
|
|
794
|
+
return _context11.abrupt("return", _context11.t0);
|
|
722
795
|
case 23:
|
|
723
|
-
|
|
796
|
+
_context11.prev = 23;
|
|
724
797
|
this.store.isLoading = false;
|
|
725
|
-
return
|
|
798
|
+
return _context11.finish(23);
|
|
726
799
|
case 26:
|
|
727
800
|
case "end":
|
|
728
|
-
return
|
|
801
|
+
return _context11.stop();
|
|
729
802
|
}
|
|
730
|
-
},
|
|
803
|
+
}, _callee11, this, [[0, 17, 23, 26]]);
|
|
731
804
|
}));
|
|
732
|
-
function verifyEmailRegistrationLink(
|
|
805
|
+
function verifyEmailRegistrationLink(_x10) {
|
|
733
806
|
return _verifyEmailRegistrationLink.apply(this, arguments);
|
|
734
807
|
}
|
|
735
808
|
return verifyEmailRegistrationLink;
|
|
@@ -741,26 +814,26 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
741
814
|
}, {
|
|
742
815
|
key: "emailPasswordLogin",
|
|
743
816
|
value: (function () {
|
|
744
|
-
var _emailPasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
817
|
+
var _emailPasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
745
818
|
var response;
|
|
746
|
-
return _regeneratorRuntime().wrap(function
|
|
747
|
-
while (1) switch (
|
|
819
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
820
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
748
821
|
case 0:
|
|
749
|
-
|
|
822
|
+
_context12.prev = 0;
|
|
750
823
|
this.store.isLoading = true;
|
|
751
824
|
this.store.error = null;
|
|
752
|
-
|
|
825
|
+
_context12.next = 5;
|
|
753
826
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
754
827
|
type: 'email-password',
|
|
755
828
|
email: params.email
|
|
756
829
|
});
|
|
757
830
|
case 5:
|
|
758
|
-
|
|
831
|
+
_context12.next = 7;
|
|
759
832
|
return this.apiCaller.call('emailPasswordLogin', params);
|
|
760
833
|
case 7:
|
|
761
|
-
response =
|
|
762
|
-
if (!(response.
|
|
763
|
-
|
|
834
|
+
response = _context12.sent;
|
|
835
|
+
if (!(response.status && response.data)) {
|
|
836
|
+
_context12.next = 17;
|
|
764
837
|
break;
|
|
765
838
|
}
|
|
766
839
|
// 保存用户信息和 token
|
|
@@ -772,46 +845,46 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
772
845
|
if (response.data.refreshToken) {
|
|
773
846
|
this.store.refreshToken = response.data.refreshToken;
|
|
774
847
|
}
|
|
775
|
-
|
|
848
|
+
_context12.next = 15;
|
|
776
849
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, {
|
|
777
850
|
user: response.data.user,
|
|
778
851
|
token: response.data.token,
|
|
779
852
|
loginType: 'email-password'
|
|
780
853
|
});
|
|
781
854
|
case 15:
|
|
782
|
-
|
|
855
|
+
_context12.next = 20;
|
|
783
856
|
break;
|
|
784
857
|
case 17:
|
|
785
858
|
this.store.error = response.message || '邮箱密码登录失败';
|
|
786
|
-
|
|
859
|
+
_context12.next = 20;
|
|
787
860
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
788
861
|
error: this.store.error,
|
|
789
862
|
loginType: 'email-password'
|
|
790
863
|
});
|
|
791
864
|
case 20:
|
|
792
|
-
return
|
|
865
|
+
return _context12.abrupt("return", response);
|
|
793
866
|
case 23:
|
|
794
|
-
|
|
795
|
-
|
|
867
|
+
_context12.prev = 23;
|
|
868
|
+
_context12.t0 = _context12["catch"](0);
|
|
796
869
|
this.store.error = '邮箱密码登录失败';
|
|
797
|
-
|
|
870
|
+
_context12.next = 28;
|
|
798
871
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
799
872
|
error: this.store.error,
|
|
800
873
|
loginType: 'email-password'
|
|
801
874
|
});
|
|
802
875
|
case 28:
|
|
803
|
-
return
|
|
876
|
+
return _context12.abrupt("return", _context12.t0);
|
|
804
877
|
case 29:
|
|
805
|
-
|
|
878
|
+
_context12.prev = 29;
|
|
806
879
|
this.store.isLoading = false;
|
|
807
|
-
return
|
|
880
|
+
return _context12.finish(29);
|
|
808
881
|
case 32:
|
|
809
882
|
case "end":
|
|
810
|
-
return
|
|
883
|
+
return _context12.stop();
|
|
811
884
|
}
|
|
812
|
-
},
|
|
885
|
+
}, _callee12, this, [[0, 23, 29, 32]]);
|
|
813
886
|
}));
|
|
814
|
-
function emailPasswordLogin(
|
|
887
|
+
function emailPasswordLogin(_x11) {
|
|
815
888
|
return _emailPasswordLogin.apply(this, arguments);
|
|
816
889
|
}
|
|
817
890
|
return emailPasswordLogin;
|
|
@@ -823,57 +896,57 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
823
896
|
}, {
|
|
824
897
|
key: "verifyCode",
|
|
825
898
|
value: (function () {
|
|
826
|
-
var _verifyCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
899
|
+
var _verifyCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
827
900
|
var response, hookName, _hookName;
|
|
828
|
-
return _regeneratorRuntime().wrap(function
|
|
829
|
-
while (1) switch (
|
|
901
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
902
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
830
903
|
case 0:
|
|
831
|
-
|
|
904
|
+
_context13.prev = 0;
|
|
832
905
|
this.store.isLoading = true;
|
|
833
906
|
this.store.error = null;
|
|
834
|
-
|
|
907
|
+
_context13.next = 5;
|
|
835
908
|
return this.apiCaller.call('verifyCode', params);
|
|
836
909
|
case 5:
|
|
837
|
-
response =
|
|
838
|
-
if (!response.
|
|
839
|
-
|
|
910
|
+
response = _context13.sent;
|
|
911
|
+
if (!response.status) {
|
|
912
|
+
_context13.next = 12;
|
|
840
913
|
break;
|
|
841
914
|
}
|
|
842
915
|
hookName = params.type === VerificationCodeType.EMAIL ? RegisterAndLoginHooks.onEmailVerificationVerified : RegisterAndLoginHooks.onSmsVerificationVerified;
|
|
843
|
-
|
|
916
|
+
_context13.next = 10;
|
|
844
917
|
return this.core.effects.emit(hookName, {
|
|
845
918
|
target: params.target,
|
|
846
919
|
purpose: params.purpose
|
|
847
920
|
});
|
|
848
921
|
case 10:
|
|
849
|
-
|
|
922
|
+
_context13.next = 16;
|
|
850
923
|
break;
|
|
851
924
|
case 12:
|
|
852
925
|
this.store.error = response.message || '验证码验证失败';
|
|
853
926
|
_hookName = params.type === VerificationCodeType.EMAIL ? RegisterAndLoginHooks.onEmailVerificationFailed : RegisterAndLoginHooks.onSmsVerificationFailed;
|
|
854
|
-
|
|
927
|
+
_context13.next = 16;
|
|
855
928
|
return this.core.effects.emit(_hookName, {
|
|
856
929
|
target: params.target,
|
|
857
930
|
error: this.store.error
|
|
858
931
|
});
|
|
859
932
|
case 16:
|
|
860
|
-
return
|
|
933
|
+
return _context13.abrupt("return", response);
|
|
861
934
|
case 19:
|
|
862
|
-
|
|
863
|
-
|
|
935
|
+
_context13.prev = 19;
|
|
936
|
+
_context13.t0 = _context13["catch"](0);
|
|
864
937
|
this.store.error = '验证码验证失败';
|
|
865
|
-
return
|
|
938
|
+
return _context13.abrupt("return", _context13.t0);
|
|
866
939
|
case 23:
|
|
867
|
-
|
|
940
|
+
_context13.prev = 23;
|
|
868
941
|
this.store.isLoading = false;
|
|
869
|
-
return
|
|
942
|
+
return _context13.finish(23);
|
|
870
943
|
case 26:
|
|
871
944
|
case "end":
|
|
872
|
-
return
|
|
945
|
+
return _context13.stop();
|
|
873
946
|
}
|
|
874
|
-
},
|
|
947
|
+
}, _callee13, this, [[0, 19, 23, 26]]);
|
|
875
948
|
}));
|
|
876
|
-
function verifyCode(
|
|
949
|
+
function verifyCode(_x12) {
|
|
877
950
|
return _verifyCode.apply(this, arguments);
|
|
878
951
|
}
|
|
879
952
|
return verifyCode;
|
|
@@ -885,23 +958,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
885
958
|
}, {
|
|
886
959
|
key: "register",
|
|
887
960
|
value: (function () {
|
|
888
|
-
var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
961
|
+
var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
889
962
|
var response, _response$data4, user, token, refreshToken, expiresAt;
|
|
890
|
-
return _regeneratorRuntime().wrap(function
|
|
891
|
-
while (1) switch (
|
|
963
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
964
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
892
965
|
case 0:
|
|
893
|
-
|
|
966
|
+
_context14.prev = 0;
|
|
894
967
|
this.store.isLoading = true;
|
|
895
968
|
this.store.error = null;
|
|
896
|
-
|
|
969
|
+
_context14.next = 5;
|
|
897
970
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterStarted, params);
|
|
898
971
|
case 5:
|
|
899
|
-
|
|
972
|
+
_context14.next = 7;
|
|
900
973
|
return this.apiCaller.call('register', params);
|
|
901
974
|
case 7:
|
|
902
|
-
response =
|
|
903
|
-
if (!(response.
|
|
904
|
-
|
|
975
|
+
response = _context14.sent;
|
|
976
|
+
if (!(response.status && response.data)) {
|
|
977
|
+
_context14.next = 15;
|
|
905
978
|
break;
|
|
906
979
|
}
|
|
907
980
|
_response$data4 = response.data, user = _response$data4.user, token = _response$data4.token, refreshToken = _response$data4.refreshToken, expiresAt = _response$data4.expiresAt; // 如果注册成功并返回了 token,说明可以直接登录
|
|
@@ -916,42 +989,42 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
916
989
|
this.window.localStorage.setItem('refresh_token', refreshToken);
|
|
917
990
|
}
|
|
918
991
|
}
|
|
919
|
-
|
|
992
|
+
_context14.next = 13;
|
|
920
993
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterSuccess, response.data);
|
|
921
994
|
case 13:
|
|
922
|
-
|
|
995
|
+
_context14.next = 18;
|
|
923
996
|
break;
|
|
924
997
|
case 15:
|
|
925
998
|
this.store.error = response.message || '注册失败';
|
|
926
|
-
|
|
999
|
+
_context14.next = 18;
|
|
927
1000
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterFailed, {
|
|
928
1001
|
error: this.store.error,
|
|
929
1002
|
params: params
|
|
930
1003
|
});
|
|
931
1004
|
case 18:
|
|
932
|
-
return
|
|
1005
|
+
return _context14.abrupt("return", response);
|
|
933
1006
|
case 21:
|
|
934
|
-
|
|
935
|
-
|
|
1007
|
+
_context14.prev = 21;
|
|
1008
|
+
_context14.t0 = _context14["catch"](0);
|
|
936
1009
|
this.store.error = '注册失败';
|
|
937
|
-
|
|
1010
|
+
_context14.next = 26;
|
|
938
1011
|
return this.core.effects.emit(RegisterAndLoginHooks.onRegisterFailed, {
|
|
939
1012
|
error: this.store.error,
|
|
940
1013
|
params: params
|
|
941
1014
|
});
|
|
942
1015
|
case 26:
|
|
943
|
-
throw
|
|
1016
|
+
throw _context14.t0;
|
|
944
1017
|
case 27:
|
|
945
|
-
|
|
1018
|
+
_context14.prev = 27;
|
|
946
1019
|
this.store.isLoading = false;
|
|
947
|
-
return
|
|
1020
|
+
return _context14.finish(27);
|
|
948
1021
|
case 30:
|
|
949
1022
|
case "end":
|
|
950
|
-
return
|
|
1023
|
+
return _context14.stop();
|
|
951
1024
|
}
|
|
952
|
-
},
|
|
1025
|
+
}, _callee14, this, [[0, 21, 27, 30]]);
|
|
953
1026
|
}));
|
|
954
|
-
function register(
|
|
1027
|
+
function register(_x13) {
|
|
955
1028
|
return _register.apply(this, arguments);
|
|
956
1029
|
}
|
|
957
1030
|
return register;
|
|
@@ -963,23 +1036,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
963
1036
|
}, {
|
|
964
1037
|
key: "login",
|
|
965
1038
|
value: (function () {
|
|
966
|
-
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1039
|
+
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
967
1040
|
var response, _response$data5, user, token, refreshToken;
|
|
968
|
-
return _regeneratorRuntime().wrap(function
|
|
969
|
-
while (1) switch (
|
|
1041
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1042
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
970
1043
|
case 0:
|
|
971
|
-
|
|
1044
|
+
_context15.prev = 0;
|
|
972
1045
|
this.store.isLoading = true;
|
|
973
1046
|
this.store.error = null;
|
|
974
|
-
|
|
1047
|
+
_context15.next = 5;
|
|
975
1048
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, params);
|
|
976
1049
|
case 5:
|
|
977
|
-
|
|
1050
|
+
_context15.next = 7;
|
|
978
1051
|
return this.apiCaller.call('login', params);
|
|
979
1052
|
case 7:
|
|
980
|
-
response =
|
|
981
|
-
if (!(response.
|
|
982
|
-
|
|
1053
|
+
response = _context15.sent;
|
|
1054
|
+
if (!(response.status && response.data)) {
|
|
1055
|
+
_context15.next = 19;
|
|
983
1056
|
break;
|
|
984
1057
|
}
|
|
985
1058
|
_response$data5 = response.data, user = _response$data5.user, token = _response$data5.token, refreshToken = _response$data5.refreshToken;
|
|
@@ -992,42 +1065,42 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
992
1065
|
if (refreshToken) {
|
|
993
1066
|
this.window.localStorage.setItem('refresh_token', refreshToken);
|
|
994
1067
|
}
|
|
995
|
-
|
|
1068
|
+
_context15.next = 17;
|
|
996
1069
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, response.data);
|
|
997
1070
|
case 17:
|
|
998
|
-
|
|
1071
|
+
_context15.next = 22;
|
|
999
1072
|
break;
|
|
1000
1073
|
case 19:
|
|
1001
1074
|
this.store.error = response.message || '登录失败';
|
|
1002
|
-
|
|
1075
|
+
_context15.next = 22;
|
|
1003
1076
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1004
1077
|
error: this.store.error,
|
|
1005
1078
|
params: params
|
|
1006
1079
|
});
|
|
1007
1080
|
case 22:
|
|
1008
|
-
return
|
|
1081
|
+
return _context15.abrupt("return", response);
|
|
1009
1082
|
case 25:
|
|
1010
|
-
|
|
1011
|
-
|
|
1083
|
+
_context15.prev = 25;
|
|
1084
|
+
_context15.t0 = _context15["catch"](0);
|
|
1012
1085
|
this.store.error = '登录失败';
|
|
1013
|
-
|
|
1086
|
+
_context15.next = 30;
|
|
1014
1087
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1015
1088
|
error: this.store.error,
|
|
1016
1089
|
params: params
|
|
1017
1090
|
});
|
|
1018
1091
|
case 30:
|
|
1019
|
-
throw
|
|
1092
|
+
throw _context15.t0;
|
|
1020
1093
|
case 31:
|
|
1021
|
-
|
|
1094
|
+
_context15.prev = 31;
|
|
1022
1095
|
this.store.isLoading = false;
|
|
1023
|
-
return
|
|
1096
|
+
return _context15.finish(31);
|
|
1024
1097
|
case 34:
|
|
1025
1098
|
case "end":
|
|
1026
|
-
return
|
|
1099
|
+
return _context15.stop();
|
|
1027
1100
|
}
|
|
1028
|
-
},
|
|
1101
|
+
}, _callee15, this, [[0, 25, 31, 34]]);
|
|
1029
1102
|
}));
|
|
1030
|
-
function login(
|
|
1103
|
+
function login(_x14) {
|
|
1031
1104
|
return _login.apply(this, arguments);
|
|
1032
1105
|
}
|
|
1033
1106
|
return login;
|
|
@@ -1039,23 +1112,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1039
1112
|
}, {
|
|
1040
1113
|
key: "oauthLogin",
|
|
1041
1114
|
value: (function () {
|
|
1042
|
-
var _oauthLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1115
|
+
var _oauthLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1043
1116
|
var response, _response$data6, user, token, refreshToken;
|
|
1044
|
-
return _regeneratorRuntime().wrap(function
|
|
1045
|
-
while (1) switch (
|
|
1117
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1118
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1046
1119
|
case 0:
|
|
1047
|
-
|
|
1120
|
+
_context16.prev = 0;
|
|
1048
1121
|
this.store.isLoading = true;
|
|
1049
1122
|
this.store.error = null;
|
|
1050
|
-
|
|
1123
|
+
_context16.next = 5;
|
|
1051
1124
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginStarted, params);
|
|
1052
1125
|
case 5:
|
|
1053
|
-
|
|
1126
|
+
_context16.next = 7;
|
|
1054
1127
|
return this.apiCaller.call('oauthLogin', params);
|
|
1055
1128
|
case 7:
|
|
1056
|
-
response =
|
|
1057
|
-
if (!(response.
|
|
1058
|
-
|
|
1129
|
+
response = _context16.sent;
|
|
1130
|
+
if (!(response.status && response.data)) {
|
|
1131
|
+
_context16.next = 19;
|
|
1059
1132
|
break;
|
|
1060
1133
|
}
|
|
1061
1134
|
_response$data6 = response.data, user = _response$data6.user, token = _response$data6.token, refreshToken = _response$data6.refreshToken;
|
|
@@ -1068,42 +1141,42 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1068
1141
|
if (refreshToken) {
|
|
1069
1142
|
this.window.localStorage.setItem('refresh_token', refreshToken);
|
|
1070
1143
|
}
|
|
1071
|
-
|
|
1144
|
+
_context16.next = 17;
|
|
1072
1145
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginSuccess, response.data);
|
|
1073
1146
|
case 17:
|
|
1074
|
-
|
|
1147
|
+
_context16.next = 22;
|
|
1075
1148
|
break;
|
|
1076
1149
|
case 19:
|
|
1077
1150
|
this.store.error = response.message || 'OAuth 登录失败';
|
|
1078
|
-
|
|
1151
|
+
_context16.next = 22;
|
|
1079
1152
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginFailed, {
|
|
1080
1153
|
error: this.store.error,
|
|
1081
1154
|
params: params
|
|
1082
1155
|
});
|
|
1083
1156
|
case 22:
|
|
1084
|
-
return
|
|
1157
|
+
return _context16.abrupt("return", response);
|
|
1085
1158
|
case 25:
|
|
1086
|
-
|
|
1087
|
-
|
|
1159
|
+
_context16.prev = 25;
|
|
1160
|
+
_context16.t0 = _context16["catch"](0);
|
|
1088
1161
|
this.store.error = 'OAuth 登录失败';
|
|
1089
|
-
|
|
1162
|
+
_context16.next = 30;
|
|
1090
1163
|
return this.core.effects.emit(RegisterAndLoginHooks.onOAuthLoginFailed, {
|
|
1091
1164
|
error: this.store.error,
|
|
1092
1165
|
params: params
|
|
1093
1166
|
});
|
|
1094
1167
|
case 30:
|
|
1095
|
-
throw
|
|
1168
|
+
throw _context16.t0;
|
|
1096
1169
|
case 31:
|
|
1097
|
-
|
|
1170
|
+
_context16.prev = 31;
|
|
1098
1171
|
this.store.isLoading = false;
|
|
1099
|
-
return
|
|
1172
|
+
return _context16.finish(31);
|
|
1100
1173
|
case 34:
|
|
1101
1174
|
case "end":
|
|
1102
|
-
return
|
|
1175
|
+
return _context16.stop();
|
|
1103
1176
|
}
|
|
1104
|
-
},
|
|
1177
|
+
}, _callee16, this, [[0, 25, 31, 34]]);
|
|
1105
1178
|
}));
|
|
1106
|
-
function oauthLogin(
|
|
1179
|
+
function oauthLogin(_x15) {
|
|
1107
1180
|
return _oauthLogin.apply(this, arguments);
|
|
1108
1181
|
}
|
|
1109
1182
|
return oauthLogin;
|
|
@@ -1115,30 +1188,30 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1115
1188
|
}, {
|
|
1116
1189
|
key: "logout",
|
|
1117
1190
|
value: (function () {
|
|
1118
|
-
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1119
|
-
return _regeneratorRuntime().wrap(function
|
|
1120
|
-
while (1) switch (
|
|
1191
|
+
var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1192
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1193
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1121
1194
|
case 0:
|
|
1122
|
-
|
|
1123
|
-
|
|
1195
|
+
_context17.prev = 0;
|
|
1196
|
+
_context17.next = 3;
|
|
1124
1197
|
return this.apiCaller.call('logout');
|
|
1125
1198
|
case 3:
|
|
1126
|
-
|
|
1199
|
+
_context17.next = 8;
|
|
1127
1200
|
break;
|
|
1128
1201
|
case 5:
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
console.warn('[RegisterAndLogin] 登出接口调用失败:',
|
|
1202
|
+
_context17.prev = 5;
|
|
1203
|
+
_context17.t0 = _context17["catch"](0);
|
|
1204
|
+
console.warn('[RegisterAndLogin] 登出接口调用失败:', _context17.t0);
|
|
1132
1205
|
case 8:
|
|
1133
|
-
|
|
1206
|
+
_context17.prev = 8;
|
|
1134
1207
|
// 无论后端接口是否成功,都清除本地状态
|
|
1135
1208
|
this.clearLoginState();
|
|
1136
|
-
return
|
|
1209
|
+
return _context17.finish(8);
|
|
1137
1210
|
case 11:
|
|
1138
1211
|
case "end":
|
|
1139
|
-
return
|
|
1212
|
+
return _context17.stop();
|
|
1140
1213
|
}
|
|
1141
|
-
},
|
|
1214
|
+
}, _callee17, this, [[0, 5, 8, 11]]);
|
|
1142
1215
|
}));
|
|
1143
1216
|
function logout() {
|
|
1144
1217
|
return _logout.apply(this, arguments);
|
|
@@ -1148,19 +1221,19 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1148
1221
|
}, {
|
|
1149
1222
|
key: "sendResetPasswordLink",
|
|
1150
1223
|
value: (function () {
|
|
1151
|
-
var _sendResetPasswordLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1224
|
+
var _sendResetPasswordLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1152
1225
|
var response;
|
|
1153
|
-
return _regeneratorRuntime().wrap(function
|
|
1154
|
-
while (1) switch (
|
|
1226
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1227
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1155
1228
|
case 0:
|
|
1156
|
-
|
|
1229
|
+
_context18.prev = 0;
|
|
1157
1230
|
this.store.isLoading = true;
|
|
1158
1231
|
this.store.error = null;
|
|
1159
|
-
|
|
1232
|
+
_context18.next = 5;
|
|
1160
1233
|
return this.apiCaller.call('sendResetPasswordLink', params);
|
|
1161
1234
|
case 5:
|
|
1162
|
-
response =
|
|
1163
|
-
if (response.
|
|
1235
|
+
response = _context18.sent;
|
|
1236
|
+
if (response.status) {
|
|
1164
1237
|
this.store.verificationCodeSent[params.email] = {
|
|
1165
1238
|
sent: true,
|
|
1166
1239
|
sentAt: Date.now(),
|
|
@@ -1173,23 +1246,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1173
1246
|
} else {
|
|
1174
1247
|
this.store.error = response.message || '发送重置密码链接失败';
|
|
1175
1248
|
}
|
|
1176
|
-
return
|
|
1249
|
+
return _context18.abrupt("return", response);
|
|
1177
1250
|
case 10:
|
|
1178
|
-
|
|
1179
|
-
|
|
1251
|
+
_context18.prev = 10;
|
|
1252
|
+
_context18.t0 = _context18["catch"](0);
|
|
1180
1253
|
this.store.error = '发送重置密码链接失败';
|
|
1181
|
-
return
|
|
1254
|
+
return _context18.abrupt("return", _context18.t0);
|
|
1182
1255
|
case 14:
|
|
1183
|
-
|
|
1256
|
+
_context18.prev = 14;
|
|
1184
1257
|
this.store.isLoading = false;
|
|
1185
|
-
return
|
|
1258
|
+
return _context18.finish(14);
|
|
1186
1259
|
case 17:
|
|
1187
1260
|
case "end":
|
|
1188
|
-
return
|
|
1261
|
+
return _context18.stop();
|
|
1189
1262
|
}
|
|
1190
|
-
},
|
|
1263
|
+
}, _callee18, this, [[0, 10, 14, 17]]);
|
|
1191
1264
|
}));
|
|
1192
|
-
function sendResetPasswordLink(
|
|
1265
|
+
function sendResetPasswordLink(_x16) {
|
|
1193
1266
|
return _sendResetPasswordLink.apply(this, arguments);
|
|
1194
1267
|
}
|
|
1195
1268
|
return sendResetPasswordLink;
|
|
@@ -1197,38 +1270,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1197
1270
|
}, {
|
|
1198
1271
|
key: "checkResetPasswordCode",
|
|
1199
1272
|
value: (function () {
|
|
1200
|
-
var _checkResetPasswordCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1273
|
+
var _checkResetPasswordCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1201
1274
|
var response;
|
|
1202
|
-
return _regeneratorRuntime().wrap(function
|
|
1203
|
-
while (1) switch (
|
|
1275
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1276
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1204
1277
|
case 0:
|
|
1205
|
-
|
|
1278
|
+
_context19.prev = 0;
|
|
1206
1279
|
this.store.isLoading = true;
|
|
1207
1280
|
this.store.error = null;
|
|
1208
|
-
|
|
1281
|
+
_context19.next = 5;
|
|
1209
1282
|
return this.apiCaller.call('checkResetPasswordCode', params);
|
|
1210
1283
|
case 5:
|
|
1211
|
-
response =
|
|
1212
|
-
if (!response.
|
|
1284
|
+
response = _context19.sent;
|
|
1285
|
+
if (!response.status) {
|
|
1213
1286
|
this.store.error = response.message || '验证码无效';
|
|
1214
1287
|
}
|
|
1215
|
-
return
|
|
1288
|
+
return _context19.abrupt("return", response);
|
|
1216
1289
|
case 10:
|
|
1217
|
-
|
|
1218
|
-
|
|
1290
|
+
_context19.prev = 10;
|
|
1291
|
+
_context19.t0 = _context19["catch"](0);
|
|
1219
1292
|
this.store.error = '验证码验证失败';
|
|
1220
|
-
return
|
|
1293
|
+
return _context19.abrupt("return", _context19.t0);
|
|
1221
1294
|
case 14:
|
|
1222
|
-
|
|
1295
|
+
_context19.prev = 14;
|
|
1223
1296
|
this.store.isLoading = false;
|
|
1224
|
-
return
|
|
1297
|
+
return _context19.finish(14);
|
|
1225
1298
|
case 17:
|
|
1226
1299
|
case "end":
|
|
1227
|
-
return
|
|
1300
|
+
return _context19.stop();
|
|
1228
1301
|
}
|
|
1229
|
-
},
|
|
1302
|
+
}, _callee19, this, [[0, 10, 14, 17]]);
|
|
1230
1303
|
}));
|
|
1231
|
-
function checkResetPasswordCode(
|
|
1304
|
+
function checkResetPasswordCode(_x17) {
|
|
1232
1305
|
return _checkResetPasswordCode.apply(this, arguments);
|
|
1233
1306
|
}
|
|
1234
1307
|
return checkResetPasswordCode;
|
|
@@ -1236,38 +1309,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1236
1309
|
}, {
|
|
1237
1310
|
key: "checkEmailLinkCode",
|
|
1238
1311
|
value: (function () {
|
|
1239
|
-
var _checkEmailLinkCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1312
|
+
var _checkEmailLinkCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1240
1313
|
var response;
|
|
1241
|
-
return _regeneratorRuntime().wrap(function
|
|
1242
|
-
while (1) switch (
|
|
1314
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1315
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1243
1316
|
case 0:
|
|
1244
|
-
|
|
1317
|
+
_context20.prev = 0;
|
|
1245
1318
|
this.store.isLoading = true;
|
|
1246
1319
|
this.store.error = null;
|
|
1247
|
-
|
|
1320
|
+
_context20.next = 5;
|
|
1248
1321
|
return this.apiCaller.call('checkEmailLinkCode', params);
|
|
1249
1322
|
case 5:
|
|
1250
|
-
response =
|
|
1251
|
-
if (!response.
|
|
1323
|
+
response = _context20.sent;
|
|
1324
|
+
if (!response.status) {
|
|
1252
1325
|
this.store.error = response.message || '邮件链接验证码无效';
|
|
1253
1326
|
}
|
|
1254
|
-
return
|
|
1327
|
+
return _context20.abrupt("return", response);
|
|
1255
1328
|
case 10:
|
|
1256
|
-
|
|
1257
|
-
|
|
1329
|
+
_context20.prev = 10;
|
|
1330
|
+
_context20.t0 = _context20["catch"](0);
|
|
1258
1331
|
this.store.error = '邮件链接验证码验证失败';
|
|
1259
|
-
return
|
|
1332
|
+
return _context20.abrupt("return", _context20.t0);
|
|
1260
1333
|
case 14:
|
|
1261
|
-
|
|
1334
|
+
_context20.prev = 14;
|
|
1262
1335
|
this.store.isLoading = false;
|
|
1263
|
-
return
|
|
1336
|
+
return _context20.finish(14);
|
|
1264
1337
|
case 17:
|
|
1265
1338
|
case "end":
|
|
1266
|
-
return
|
|
1339
|
+
return _context20.stop();
|
|
1267
1340
|
}
|
|
1268
|
-
},
|
|
1341
|
+
}, _callee20, this, [[0, 10, 14, 17]]);
|
|
1269
1342
|
}));
|
|
1270
|
-
function checkEmailLinkCode(
|
|
1343
|
+
function checkEmailLinkCode(_x18) {
|
|
1271
1344
|
return _checkEmailLinkCode.apply(this, arguments);
|
|
1272
1345
|
}
|
|
1273
1346
|
return checkEmailLinkCode;
|
|
@@ -1275,22 +1348,22 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1275
1348
|
}, {
|
|
1276
1349
|
key: "resetPasswordByCode",
|
|
1277
1350
|
value: (function () {
|
|
1278
|
-
var _resetPasswordByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1351
|
+
var _resetPasswordByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
1279
1352
|
var response;
|
|
1280
|
-
return _regeneratorRuntime().wrap(function
|
|
1281
|
-
while (1) switch (
|
|
1353
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1354
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1282
1355
|
case 0:
|
|
1283
|
-
|
|
1356
|
+
_context21.prev = 0;
|
|
1284
1357
|
this.store.isLoading = true;
|
|
1285
1358
|
this.store.error = null;
|
|
1286
1359
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetStarted, {
|
|
1287
1360
|
code: params.code
|
|
1288
1361
|
});
|
|
1289
|
-
|
|
1362
|
+
_context21.next = 6;
|
|
1290
1363
|
return this.apiCaller.call('resetPasswordByCode', params);
|
|
1291
1364
|
case 6:
|
|
1292
|
-
response =
|
|
1293
|
-
if (response.
|
|
1365
|
+
response = _context21.sent;
|
|
1366
|
+
if (response.status) {
|
|
1294
1367
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetSuccess, {
|
|
1295
1368
|
code: params.code
|
|
1296
1369
|
});
|
|
@@ -1301,27 +1374,27 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1301
1374
|
error: this.store.error
|
|
1302
1375
|
});
|
|
1303
1376
|
}
|
|
1304
|
-
return
|
|
1377
|
+
return _context21.abrupt("return", response);
|
|
1305
1378
|
case 11:
|
|
1306
|
-
|
|
1307
|
-
|
|
1379
|
+
_context21.prev = 11;
|
|
1380
|
+
_context21.t0 = _context21["catch"](0);
|
|
1308
1381
|
this.store.error = '密码重置失败';
|
|
1309
1382
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetFailed, {
|
|
1310
1383
|
code: params.code,
|
|
1311
1384
|
error: this.store.error
|
|
1312
1385
|
});
|
|
1313
|
-
return
|
|
1386
|
+
return _context21.abrupt("return", _context21.t0);
|
|
1314
1387
|
case 16:
|
|
1315
|
-
|
|
1388
|
+
_context21.prev = 16;
|
|
1316
1389
|
this.store.isLoading = false;
|
|
1317
|
-
return
|
|
1390
|
+
return _context21.finish(16);
|
|
1318
1391
|
case 19:
|
|
1319
1392
|
case "end":
|
|
1320
|
-
return
|
|
1393
|
+
return _context21.stop();
|
|
1321
1394
|
}
|
|
1322
|
-
},
|
|
1395
|
+
}, _callee21, this, [[0, 11, 16, 19]]);
|
|
1323
1396
|
}));
|
|
1324
|
-
function resetPasswordByCode(
|
|
1397
|
+
function resetPasswordByCode(_x19) {
|
|
1325
1398
|
return _resetPasswordByCode.apply(this, arguments);
|
|
1326
1399
|
}
|
|
1327
1400
|
return resetPasswordByCode;
|
|
@@ -1333,12 +1406,12 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1333
1406
|
}, {
|
|
1334
1407
|
key: "resetPassword",
|
|
1335
1408
|
value: (function () {
|
|
1336
|
-
var _resetPassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1409
|
+
var _resetPassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
1337
1410
|
var response, key;
|
|
1338
|
-
return _regeneratorRuntime().wrap(function
|
|
1339
|
-
while (1) switch (
|
|
1411
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1412
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1340
1413
|
case 0:
|
|
1341
|
-
|
|
1414
|
+
_context22.prev = 0;
|
|
1342
1415
|
this.store.isLoading = true;
|
|
1343
1416
|
this.store.error = null;
|
|
1344
1417
|
|
|
@@ -1353,33 +1426,33 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1353
1426
|
});
|
|
1354
1427
|
}
|
|
1355
1428
|
if (!(params.type === 'email')) {
|
|
1356
|
-
|
|
1429
|
+
_context22.next = 12;
|
|
1357
1430
|
break;
|
|
1358
1431
|
}
|
|
1359
1432
|
if (params.target.email) {
|
|
1360
|
-
|
|
1433
|
+
_context22.next = 7;
|
|
1361
1434
|
break;
|
|
1362
1435
|
}
|
|
1363
1436
|
throw new Error('邮箱地址不能为空');
|
|
1364
1437
|
case 7:
|
|
1365
|
-
|
|
1438
|
+
_context22.next = 9;
|
|
1366
1439
|
return this.apiCaller.call('resetPasswordByEmail', {
|
|
1367
1440
|
email: params.target.email,
|
|
1368
1441
|
password: params.password,
|
|
1369
1442
|
code: params.code
|
|
1370
1443
|
});
|
|
1371
1444
|
case 9:
|
|
1372
|
-
response =
|
|
1373
|
-
|
|
1445
|
+
response = _context22.sent;
|
|
1446
|
+
_context22.next = 17;
|
|
1374
1447
|
break;
|
|
1375
1448
|
case 12:
|
|
1376
1449
|
if (!(!params.target.phone || !params.target.country_calling_code)) {
|
|
1377
|
-
|
|
1450
|
+
_context22.next = 14;
|
|
1378
1451
|
break;
|
|
1379
1452
|
}
|
|
1380
1453
|
throw new Error('手机号和国家区号不能为空');
|
|
1381
1454
|
case 14:
|
|
1382
|
-
|
|
1455
|
+
_context22.next = 16;
|
|
1383
1456
|
return this.apiCaller.call('resetPasswordByPhone', {
|
|
1384
1457
|
phone: params.target.phone,
|
|
1385
1458
|
password: params.password,
|
|
@@ -1387,9 +1460,9 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1387
1460
|
country_calling_code: params.target.country_calling_code
|
|
1388
1461
|
});
|
|
1389
1462
|
case 16:
|
|
1390
|
-
response =
|
|
1463
|
+
response = _context22.sent;
|
|
1391
1464
|
case 17:
|
|
1392
|
-
if (response.
|
|
1465
|
+
if (response.status) {
|
|
1393
1466
|
// 清除验证码发送状态
|
|
1394
1467
|
key = params.type === 'email' ? params.target.email : params.target.phone;
|
|
1395
1468
|
if (this.store.verificationCodeSent[key]) {
|
|
@@ -1418,10 +1491,10 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1418
1491
|
});
|
|
1419
1492
|
}
|
|
1420
1493
|
}
|
|
1421
|
-
return
|
|
1494
|
+
return _context22.abrupt("return", response);
|
|
1422
1495
|
case 21:
|
|
1423
|
-
|
|
1424
|
-
|
|
1496
|
+
_context22.prev = 21;
|
|
1497
|
+
_context22.t0 = _context22["catch"](0);
|
|
1425
1498
|
this.store.error = '密码重置失败';
|
|
1426
1499
|
if (params.type === 'email') {
|
|
1427
1500
|
this.core.effects.emit(RegisterAndLoginHooks.onPasswordResetFailed, {
|
|
@@ -1434,18 +1507,18 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1434
1507
|
error: this.store.error
|
|
1435
1508
|
});
|
|
1436
1509
|
}
|
|
1437
|
-
return
|
|
1510
|
+
return _context22.abrupt("return", _context22.t0);
|
|
1438
1511
|
case 26:
|
|
1439
|
-
|
|
1512
|
+
_context22.prev = 26;
|
|
1440
1513
|
this.store.isLoading = false;
|
|
1441
|
-
return
|
|
1514
|
+
return _context22.finish(26);
|
|
1442
1515
|
case 29:
|
|
1443
1516
|
case "end":
|
|
1444
|
-
return
|
|
1517
|
+
return _context22.stop();
|
|
1445
1518
|
}
|
|
1446
|
-
},
|
|
1519
|
+
}, _callee22, this, [[0, 21, 26, 29]]);
|
|
1447
1520
|
}));
|
|
1448
|
-
function resetPassword(
|
|
1521
|
+
function resetPassword(_x20) {
|
|
1449
1522
|
return _resetPassword.apply(this, arguments);
|
|
1450
1523
|
}
|
|
1451
1524
|
return resetPassword;
|
|
@@ -1453,20 +1526,20 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1453
1526
|
}, {
|
|
1454
1527
|
key: "sendSmsLoginCode",
|
|
1455
1528
|
value: (function () {
|
|
1456
|
-
var _sendSmsLoginCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1529
|
+
var _sendSmsLoginCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
1457
1530
|
var response, now;
|
|
1458
|
-
return _regeneratorRuntime().wrap(function
|
|
1459
|
-
while (1) switch (
|
|
1531
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1532
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1460
1533
|
case 0:
|
|
1461
|
-
|
|
1534
|
+
_context23.prev = 0;
|
|
1462
1535
|
this.store.isLoading = true;
|
|
1463
1536
|
this.store.error = null;
|
|
1464
|
-
|
|
1537
|
+
_context23.next = 5;
|
|
1465
1538
|
return this.apiCaller.call('sendSmsLoginCode', params);
|
|
1466
1539
|
case 5:
|
|
1467
|
-
response =
|
|
1468
|
-
if (!response.
|
|
1469
|
-
|
|
1540
|
+
response = _context23.sent;
|
|
1541
|
+
if (!response.status) {
|
|
1542
|
+
_context23.next = 13;
|
|
1470
1543
|
break;
|
|
1471
1544
|
}
|
|
1472
1545
|
// 记录验证码发送状态
|
|
@@ -1476,45 +1549,45 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1476
1549
|
sentAt: now,
|
|
1477
1550
|
expiresAt: now + 5 * 60 * 1000 // 5分钟过期
|
|
1478
1551
|
};
|
|
1479
|
-
|
|
1552
|
+
_context23.next = 11;
|
|
1480
1553
|
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationSent, {
|
|
1481
1554
|
target: params.phone,
|
|
1482
1555
|
purpose: VerificationPurpose.LOGIN
|
|
1483
1556
|
});
|
|
1484
1557
|
case 11:
|
|
1485
|
-
|
|
1558
|
+
_context23.next = 16;
|
|
1486
1559
|
break;
|
|
1487
1560
|
case 13:
|
|
1488
1561
|
this.store.error = response.message || '发送登录验证码失败';
|
|
1489
|
-
|
|
1562
|
+
_context23.next = 16;
|
|
1490
1563
|
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
1491
1564
|
target: params.phone,
|
|
1492
1565
|
error: this.store.error
|
|
1493
1566
|
});
|
|
1494
1567
|
case 16:
|
|
1495
|
-
return
|
|
1568
|
+
return _context23.abrupt("return", response);
|
|
1496
1569
|
case 19:
|
|
1497
|
-
|
|
1498
|
-
|
|
1570
|
+
_context23.prev = 19;
|
|
1571
|
+
_context23.t0 = _context23["catch"](0);
|
|
1499
1572
|
this.store.error = '发送登录验证码失败';
|
|
1500
|
-
|
|
1573
|
+
_context23.next = 24;
|
|
1501
1574
|
return this.core.effects.emit(RegisterAndLoginHooks.onSmsVerificationFailed, {
|
|
1502
1575
|
target: params.phone,
|
|
1503
1576
|
error: this.store.error
|
|
1504
1577
|
});
|
|
1505
1578
|
case 24:
|
|
1506
|
-
return
|
|
1579
|
+
return _context23.abrupt("return", _context23.t0);
|
|
1507
1580
|
case 25:
|
|
1508
|
-
|
|
1581
|
+
_context23.prev = 25;
|
|
1509
1582
|
this.store.isLoading = false;
|
|
1510
|
-
return
|
|
1583
|
+
return _context23.finish(25);
|
|
1511
1584
|
case 28:
|
|
1512
1585
|
case "end":
|
|
1513
|
-
return
|
|
1586
|
+
return _context23.stop();
|
|
1514
1587
|
}
|
|
1515
|
-
},
|
|
1588
|
+
}, _callee23, this, [[0, 19, 25, 28]]);
|
|
1516
1589
|
}));
|
|
1517
|
-
function sendSmsLoginCode(
|
|
1590
|
+
function sendSmsLoginCode(_x21) {
|
|
1518
1591
|
return _sendSmsLoginCode.apply(this, arguments);
|
|
1519
1592
|
}
|
|
1520
1593
|
return sendSmsLoginCode;
|
|
@@ -1522,26 +1595,26 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1522
1595
|
}, {
|
|
1523
1596
|
key: "phoneCodeLogin",
|
|
1524
1597
|
value: (function () {
|
|
1525
|
-
var _phoneCodeLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1598
|
+
var _phoneCodeLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
1526
1599
|
var response;
|
|
1527
|
-
return _regeneratorRuntime().wrap(function
|
|
1528
|
-
while (1) switch (
|
|
1600
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1601
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1529
1602
|
case 0:
|
|
1530
|
-
|
|
1603
|
+
_context24.prev = 0;
|
|
1531
1604
|
this.store.isLoading = true;
|
|
1532
1605
|
this.store.error = null;
|
|
1533
|
-
|
|
1606
|
+
_context24.next = 5;
|
|
1534
1607
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1535
1608
|
type: 'phone-code',
|
|
1536
1609
|
phone: params.phone
|
|
1537
1610
|
});
|
|
1538
1611
|
case 5:
|
|
1539
|
-
|
|
1612
|
+
_context24.next = 7;
|
|
1540
1613
|
return this.apiCaller.call('phoneCodeLogin', params);
|
|
1541
1614
|
case 7:
|
|
1542
|
-
response =
|
|
1543
|
-
if (!(response.
|
|
1544
|
-
|
|
1615
|
+
response = _context24.sent;
|
|
1616
|
+
if (!(response.status && response.data)) {
|
|
1617
|
+
_context24.next = 17;
|
|
1545
1618
|
break;
|
|
1546
1619
|
}
|
|
1547
1620
|
// 保存用户信息和 token
|
|
@@ -1553,46 +1626,46 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1553
1626
|
if (response.data.refreshToken) {
|
|
1554
1627
|
this.store.refreshToken = response.data.refreshToken;
|
|
1555
1628
|
}
|
|
1556
|
-
|
|
1629
|
+
_context24.next = 15;
|
|
1557
1630
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginSuccess, {
|
|
1558
1631
|
user: response.data.user,
|
|
1559
1632
|
token: response.data.token,
|
|
1560
1633
|
loginType: 'phone-code'
|
|
1561
1634
|
});
|
|
1562
1635
|
case 15:
|
|
1563
|
-
|
|
1636
|
+
_context24.next = 20;
|
|
1564
1637
|
break;
|
|
1565
1638
|
case 17:
|
|
1566
1639
|
this.store.error = response.message || '手机号验证码登录失败';
|
|
1567
|
-
|
|
1640
|
+
_context24.next = 20;
|
|
1568
1641
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1569
1642
|
error: this.store.error,
|
|
1570
1643
|
loginType: 'phone-code'
|
|
1571
1644
|
});
|
|
1572
1645
|
case 20:
|
|
1573
|
-
return
|
|
1646
|
+
return _context24.abrupt("return", response);
|
|
1574
1647
|
case 23:
|
|
1575
|
-
|
|
1576
|
-
|
|
1648
|
+
_context24.prev = 23;
|
|
1649
|
+
_context24.t0 = _context24["catch"](0);
|
|
1577
1650
|
this.store.error = '手机号验证码登录失败';
|
|
1578
|
-
|
|
1651
|
+
_context24.next = 28;
|
|
1579
1652
|
return this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1580
1653
|
error: this.store.error,
|
|
1581
1654
|
loginType: 'phone-code'
|
|
1582
1655
|
});
|
|
1583
1656
|
case 28:
|
|
1584
|
-
return
|
|
1657
|
+
return _context24.abrupt("return", _context24.t0);
|
|
1585
1658
|
case 29:
|
|
1586
|
-
|
|
1659
|
+
_context24.prev = 29;
|
|
1587
1660
|
this.store.isLoading = false;
|
|
1588
|
-
return
|
|
1661
|
+
return _context24.finish(29);
|
|
1589
1662
|
case 32:
|
|
1590
1663
|
case "end":
|
|
1591
|
-
return
|
|
1664
|
+
return _context24.stop();
|
|
1592
1665
|
}
|
|
1593
|
-
},
|
|
1666
|
+
}, _callee24, this, [[0, 23, 29, 32]]);
|
|
1594
1667
|
}));
|
|
1595
|
-
function phoneCodeLogin(
|
|
1668
|
+
function phoneCodeLogin(_x22) {
|
|
1596
1669
|
return _phoneCodeLogin.apply(this, arguments);
|
|
1597
1670
|
}
|
|
1598
1671
|
return phoneCodeLogin;
|
|
@@ -1600,22 +1673,22 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1600
1673
|
}, {
|
|
1601
1674
|
key: "guestLogin",
|
|
1602
1675
|
value: (function () {
|
|
1603
|
-
var _guestLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1676
|
+
var _guestLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1604
1677
|
var response;
|
|
1605
|
-
return _regeneratorRuntime().wrap(function
|
|
1606
|
-
while (1) switch (
|
|
1678
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1679
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1607
1680
|
case 0:
|
|
1608
|
-
|
|
1681
|
+
_context25.prev = 0;
|
|
1609
1682
|
this.store.isLoading = true;
|
|
1610
1683
|
this.store.error = null;
|
|
1611
1684
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1612
1685
|
type: 'guest'
|
|
1613
1686
|
});
|
|
1614
|
-
|
|
1687
|
+
_context25.next = 6;
|
|
1615
1688
|
return this.apiCaller.call('guestLogin', this.channel);
|
|
1616
1689
|
case 6:
|
|
1617
|
-
response =
|
|
1618
|
-
if (response.
|
|
1690
|
+
response = _context25.sent;
|
|
1691
|
+
if (response.status && response.data) {
|
|
1619
1692
|
// 保存用户信息和 token
|
|
1620
1693
|
this.store.isLoggedIn = true;
|
|
1621
1694
|
this.store.userInfo = response.data.user;
|
|
@@ -1637,25 +1710,25 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1637
1710
|
loginType: 'guest'
|
|
1638
1711
|
});
|
|
1639
1712
|
}
|
|
1640
|
-
return
|
|
1713
|
+
return _context25.abrupt("return", response);
|
|
1641
1714
|
case 11:
|
|
1642
|
-
|
|
1643
|
-
|
|
1715
|
+
_context25.prev = 11;
|
|
1716
|
+
_context25.t0 = _context25["catch"](0);
|
|
1644
1717
|
this.store.error = 'Guest 登录失败';
|
|
1645
1718
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1646
1719
|
error: this.store.error,
|
|
1647
1720
|
loginType: 'guest'
|
|
1648
1721
|
});
|
|
1649
|
-
return
|
|
1722
|
+
return _context25.abrupt("return", _context25.t0);
|
|
1650
1723
|
case 16:
|
|
1651
|
-
|
|
1724
|
+
_context25.prev = 16;
|
|
1652
1725
|
this.store.isLoading = false;
|
|
1653
|
-
return
|
|
1726
|
+
return _context25.finish(16);
|
|
1654
1727
|
case 19:
|
|
1655
1728
|
case "end":
|
|
1656
|
-
return
|
|
1729
|
+
return _context25.stop();
|
|
1657
1730
|
}
|
|
1658
|
-
},
|
|
1731
|
+
}, _callee25, this, [[0, 11, 16, 19]]);
|
|
1659
1732
|
}));
|
|
1660
1733
|
function guestLogin() {
|
|
1661
1734
|
return _guestLogin.apply(this, arguments);
|
|
@@ -1665,38 +1738,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1665
1738
|
}, {
|
|
1666
1739
|
key: "checkEmailExists",
|
|
1667
1740
|
value: (function () {
|
|
1668
|
-
var _checkEmailExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1741
|
+
var _checkEmailExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
1669
1742
|
var response;
|
|
1670
|
-
return _regeneratorRuntime().wrap(function
|
|
1671
|
-
while (1) switch (
|
|
1743
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1744
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1672
1745
|
case 0:
|
|
1673
|
-
|
|
1746
|
+
_context26.prev = 0;
|
|
1674
1747
|
this.store.isLoading = true;
|
|
1675
1748
|
this.store.error = null;
|
|
1676
|
-
|
|
1749
|
+
_context26.next = 5;
|
|
1677
1750
|
return this.apiCaller.call('checkEmailExists', params);
|
|
1678
1751
|
case 5:
|
|
1679
|
-
response =
|
|
1680
|
-
if (!response.
|
|
1752
|
+
response = _context26.sent;
|
|
1753
|
+
if (!response.status) {
|
|
1681
1754
|
this.store.error = response.message || '检查邮箱失败';
|
|
1682
1755
|
}
|
|
1683
|
-
return
|
|
1756
|
+
return _context26.abrupt("return", response);
|
|
1684
1757
|
case 10:
|
|
1685
|
-
|
|
1686
|
-
|
|
1758
|
+
_context26.prev = 10;
|
|
1759
|
+
_context26.t0 = _context26["catch"](0);
|
|
1687
1760
|
this.store.error = '检查邮箱失败';
|
|
1688
|
-
return
|
|
1761
|
+
return _context26.abrupt("return", _context26.t0);
|
|
1689
1762
|
case 14:
|
|
1690
|
-
|
|
1763
|
+
_context26.prev = 14;
|
|
1691
1764
|
this.store.isLoading = false;
|
|
1692
|
-
return
|
|
1765
|
+
return _context26.finish(14);
|
|
1693
1766
|
case 17:
|
|
1694
1767
|
case "end":
|
|
1695
|
-
return
|
|
1768
|
+
return _context26.stop();
|
|
1696
1769
|
}
|
|
1697
|
-
},
|
|
1770
|
+
}, _callee26, this, [[0, 10, 14, 17]]);
|
|
1698
1771
|
}));
|
|
1699
|
-
function checkEmailExists(
|
|
1772
|
+
function checkEmailExists(_x23) {
|
|
1700
1773
|
return _checkEmailExists.apply(this, arguments);
|
|
1701
1774
|
}
|
|
1702
1775
|
return checkEmailExists;
|
|
@@ -1704,38 +1777,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1704
1777
|
}, {
|
|
1705
1778
|
key: "checkEmailCode",
|
|
1706
1779
|
value: (function () {
|
|
1707
|
-
var _checkEmailCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1780
|
+
var _checkEmailCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
1708
1781
|
var response;
|
|
1709
|
-
return _regeneratorRuntime().wrap(function
|
|
1710
|
-
while (1) switch (
|
|
1782
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1783
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1711
1784
|
case 0:
|
|
1712
|
-
|
|
1785
|
+
_context27.prev = 0;
|
|
1713
1786
|
this.store.isLoading = true;
|
|
1714
1787
|
this.store.error = null;
|
|
1715
|
-
|
|
1788
|
+
_context27.next = 5;
|
|
1716
1789
|
return this.apiCaller.call('checkEmailCode', params);
|
|
1717
1790
|
case 5:
|
|
1718
|
-
response =
|
|
1719
|
-
if (!response.
|
|
1791
|
+
response = _context27.sent;
|
|
1792
|
+
if (!response.status) {
|
|
1720
1793
|
this.store.error = response.message || '检查邮箱验证码失败';
|
|
1721
1794
|
}
|
|
1722
|
-
return
|
|
1795
|
+
return _context27.abrupt("return", response);
|
|
1723
1796
|
case 10:
|
|
1724
|
-
|
|
1725
|
-
|
|
1797
|
+
_context27.prev = 10;
|
|
1798
|
+
_context27.t0 = _context27["catch"](0);
|
|
1726
1799
|
this.store.error = '检查邮箱验证码失败';
|
|
1727
|
-
return
|
|
1800
|
+
return _context27.abrupt("return", _context27.t0);
|
|
1728
1801
|
case 14:
|
|
1729
|
-
|
|
1802
|
+
_context27.prev = 14;
|
|
1730
1803
|
this.store.isLoading = false;
|
|
1731
|
-
return
|
|
1804
|
+
return _context27.finish(14);
|
|
1732
1805
|
case 17:
|
|
1733
1806
|
case "end":
|
|
1734
|
-
return
|
|
1807
|
+
return _context27.stop();
|
|
1735
1808
|
}
|
|
1736
|
-
},
|
|
1809
|
+
}, _callee27, this, [[0, 10, 14, 17]]);
|
|
1737
1810
|
}));
|
|
1738
|
-
function checkEmailCode(
|
|
1811
|
+
function checkEmailCode(_x24) {
|
|
1739
1812
|
return _checkEmailCode.apply(this, arguments);
|
|
1740
1813
|
}
|
|
1741
1814
|
return checkEmailCode;
|
|
@@ -1743,38 +1816,38 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1743
1816
|
}, {
|
|
1744
1817
|
key: "checkMobileCode",
|
|
1745
1818
|
value: (function () {
|
|
1746
|
-
var _checkMobileCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1819
|
+
var _checkMobileCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
1747
1820
|
var response;
|
|
1748
|
-
return _regeneratorRuntime().wrap(function
|
|
1749
|
-
while (1) switch (
|
|
1821
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1822
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1750
1823
|
case 0:
|
|
1751
|
-
|
|
1824
|
+
_context28.prev = 0;
|
|
1752
1825
|
this.store.isLoading = true;
|
|
1753
1826
|
this.store.error = null;
|
|
1754
|
-
|
|
1827
|
+
_context28.next = 5;
|
|
1755
1828
|
return this.apiCaller.call('checkMobileCode', params);
|
|
1756
1829
|
case 5:
|
|
1757
|
-
response =
|
|
1758
|
-
if (!response.
|
|
1830
|
+
response = _context28.sent;
|
|
1831
|
+
if (!response.status) {
|
|
1759
1832
|
this.store.error = response.message || '检查手机验证码失败';
|
|
1760
1833
|
}
|
|
1761
|
-
return
|
|
1834
|
+
return _context28.abrupt("return", response);
|
|
1762
1835
|
case 10:
|
|
1763
|
-
|
|
1764
|
-
|
|
1836
|
+
_context28.prev = 10;
|
|
1837
|
+
_context28.t0 = _context28["catch"](0);
|
|
1765
1838
|
this.store.error = '检查手机验证码失败';
|
|
1766
|
-
return
|
|
1839
|
+
return _context28.abrupt("return", _context28.t0);
|
|
1767
1840
|
case 14:
|
|
1768
|
-
|
|
1841
|
+
_context28.prev = 14;
|
|
1769
1842
|
this.store.isLoading = false;
|
|
1770
|
-
return
|
|
1843
|
+
return _context28.finish(14);
|
|
1771
1844
|
case 17:
|
|
1772
1845
|
case "end":
|
|
1773
|
-
return
|
|
1846
|
+
return _context28.stop();
|
|
1774
1847
|
}
|
|
1775
|
-
},
|
|
1848
|
+
}, _callee28, this, [[0, 10, 14, 17]]);
|
|
1776
1849
|
}));
|
|
1777
|
-
function checkMobileCode(
|
|
1850
|
+
function checkMobileCode(_x25) {
|
|
1778
1851
|
return _checkMobileCode.apply(this, arguments);
|
|
1779
1852
|
}
|
|
1780
1853
|
return checkMobileCode;
|
|
@@ -1782,23 +1855,23 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1782
1855
|
}, {
|
|
1783
1856
|
key: "phonePasswordLogin",
|
|
1784
1857
|
value: (function () {
|
|
1785
|
-
var _phonePasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1858
|
+
var _phonePasswordLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
1786
1859
|
var response;
|
|
1787
|
-
return _regeneratorRuntime().wrap(function
|
|
1788
|
-
while (1) switch (
|
|
1860
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1861
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1789
1862
|
case 0:
|
|
1790
|
-
|
|
1863
|
+
_context29.prev = 0;
|
|
1791
1864
|
this.store.isLoading = true;
|
|
1792
1865
|
this.store.error = null;
|
|
1793
1866
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginStarted, {
|
|
1794
1867
|
type: 'phone-password',
|
|
1795
1868
|
phone: params.phone
|
|
1796
1869
|
});
|
|
1797
|
-
|
|
1870
|
+
_context29.next = 6;
|
|
1798
1871
|
return this.apiCaller.call('phonePasswordLogin', params);
|
|
1799
1872
|
case 6:
|
|
1800
|
-
response =
|
|
1801
|
-
if (response.
|
|
1873
|
+
response = _context29.sent;
|
|
1874
|
+
if (response.status && response.data) {
|
|
1802
1875
|
// 保存用户信息和 token
|
|
1803
1876
|
this.store.isLoggedIn = true;
|
|
1804
1877
|
this.store.userInfo = response.data.user;
|
|
@@ -1820,27 +1893,27 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1820
1893
|
loginType: 'phone-password'
|
|
1821
1894
|
});
|
|
1822
1895
|
}
|
|
1823
|
-
return
|
|
1896
|
+
return _context29.abrupt("return", response);
|
|
1824
1897
|
case 11:
|
|
1825
|
-
|
|
1826
|
-
|
|
1898
|
+
_context29.prev = 11;
|
|
1899
|
+
_context29.t0 = _context29["catch"](0);
|
|
1827
1900
|
this.store.error = '手机号密码登录失败';
|
|
1828
1901
|
this.core.effects.emit(RegisterAndLoginHooks.onLoginFailed, {
|
|
1829
1902
|
error: this.store.error,
|
|
1830
1903
|
loginType: 'phone-password'
|
|
1831
1904
|
});
|
|
1832
|
-
return
|
|
1905
|
+
return _context29.abrupt("return", _context29.t0);
|
|
1833
1906
|
case 16:
|
|
1834
|
-
|
|
1907
|
+
_context29.prev = 16;
|
|
1835
1908
|
this.store.isLoading = false;
|
|
1836
|
-
return
|
|
1909
|
+
return _context29.finish(16);
|
|
1837
1910
|
case 19:
|
|
1838
1911
|
case "end":
|
|
1839
|
-
return
|
|
1912
|
+
return _context29.stop();
|
|
1840
1913
|
}
|
|
1841
|
-
},
|
|
1914
|
+
}, _callee29, this, [[0, 11, 16, 19]]);
|
|
1842
1915
|
}));
|
|
1843
|
-
function phonePasswordLogin(
|
|
1916
|
+
function phonePasswordLogin(_x26) {
|
|
1844
1917
|
return _phonePasswordLogin.apply(this, arguments);
|
|
1845
1918
|
}
|
|
1846
1919
|
return phonePasswordLogin;
|
|
@@ -1848,19 +1921,19 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1921
|
}, {
|
|
1849
1922
|
key: "sendPasswordResetEmail",
|
|
1850
1923
|
value: (function () {
|
|
1851
|
-
var _sendPasswordResetEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1924
|
+
var _sendPasswordResetEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
1852
1925
|
var response, now;
|
|
1853
|
-
return _regeneratorRuntime().wrap(function
|
|
1854
|
-
while (1) switch (
|
|
1926
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
1927
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1855
1928
|
case 0:
|
|
1856
|
-
|
|
1929
|
+
_context30.prev = 0;
|
|
1857
1930
|
this.store.isLoading = true;
|
|
1858
1931
|
this.store.error = null;
|
|
1859
|
-
|
|
1932
|
+
_context30.next = 5;
|
|
1860
1933
|
return this.apiCaller.call('sendPasswordResetEmail', params);
|
|
1861
1934
|
case 5:
|
|
1862
|
-
response =
|
|
1863
|
-
if (response.
|
|
1935
|
+
response = _context30.sent;
|
|
1936
|
+
if (response.status) {
|
|
1864
1937
|
// 记录验证码发送状态
|
|
1865
1938
|
now = Date.now();
|
|
1866
1939
|
this.store.verificationCodeSent[params.email] = {
|
|
@@ -1879,27 +1952,27 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1879
1952
|
error: this.store.error
|
|
1880
1953
|
});
|
|
1881
1954
|
}
|
|
1882
|
-
return
|
|
1955
|
+
return _context30.abrupt("return", response);
|
|
1883
1956
|
case 10:
|
|
1884
|
-
|
|
1885
|
-
|
|
1957
|
+
_context30.prev = 10;
|
|
1958
|
+
_context30.t0 = _context30["catch"](0);
|
|
1886
1959
|
this.store.error = '发送密码重置验证码失败';
|
|
1887
1960
|
this.core.effects.emit(RegisterAndLoginHooks.onEmailVerificationFailed, {
|
|
1888
1961
|
target: params.email,
|
|
1889
1962
|
error: this.store.error
|
|
1890
1963
|
});
|
|
1891
|
-
return
|
|
1964
|
+
return _context30.abrupt("return", _context30.t0);
|
|
1892
1965
|
case 15:
|
|
1893
|
-
|
|
1966
|
+
_context30.prev = 15;
|
|
1894
1967
|
this.store.isLoading = false;
|
|
1895
|
-
return
|
|
1968
|
+
return _context30.finish(15);
|
|
1896
1969
|
case 18:
|
|
1897
1970
|
case "end":
|
|
1898
|
-
return
|
|
1971
|
+
return _context30.stop();
|
|
1899
1972
|
}
|
|
1900
|
-
},
|
|
1973
|
+
}, _callee30, this, [[0, 10, 15, 18]]);
|
|
1901
1974
|
}));
|
|
1902
|
-
function sendPasswordResetEmail(
|
|
1975
|
+
function sendPasswordResetEmail(_x27) {
|
|
1903
1976
|
return _sendPasswordResetEmail.apply(this, arguments);
|
|
1904
1977
|
}
|
|
1905
1978
|
return sendPasswordResetEmail;
|
|
@@ -1907,43 +1980,43 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1907
1980
|
}, {
|
|
1908
1981
|
key: "sendPasswordResetSms",
|
|
1909
1982
|
value: (function () {
|
|
1910
|
-
var _sendPasswordResetSms = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1983
|
+
var _sendPasswordResetSms = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
1911
1984
|
var response;
|
|
1912
|
-
return _regeneratorRuntime().wrap(function
|
|
1913
|
-
while (1) switch (
|
|
1985
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
1986
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1914
1987
|
case 0:
|
|
1915
|
-
|
|
1988
|
+
_context31.prev = 0;
|
|
1916
1989
|
this.store.isLoading = true;
|
|
1917
1990
|
this.store.error = null;
|
|
1918
|
-
|
|
1991
|
+
_context31.next = 5;
|
|
1919
1992
|
return this.apiCaller.call('sendPasswordResetSms', params);
|
|
1920
1993
|
case 5:
|
|
1921
|
-
response =
|
|
1922
|
-
if (!response.
|
|
1923
|
-
|
|
1994
|
+
response = _context31.sent;
|
|
1995
|
+
if (!response.status) {
|
|
1996
|
+
_context31.next = 10;
|
|
1924
1997
|
break;
|
|
1925
1998
|
}
|
|
1926
|
-
return
|
|
1999
|
+
return _context31.abrupt("return", response);
|
|
1927
2000
|
case 10:
|
|
1928
2001
|
this.store.error = response.message || '发送手机号验证码重置密码失败';
|
|
1929
2002
|
case 11:
|
|
1930
|
-
return
|
|
2003
|
+
return _context31.abrupt("return", response);
|
|
1931
2004
|
case 14:
|
|
1932
|
-
|
|
1933
|
-
|
|
2005
|
+
_context31.prev = 14;
|
|
2006
|
+
_context31.t0 = _context31["catch"](0);
|
|
1934
2007
|
this.store.error = '发送手机号验证码重置密码失败';
|
|
1935
|
-
return
|
|
2008
|
+
return _context31.abrupt("return", _context31.t0);
|
|
1936
2009
|
case 18:
|
|
1937
|
-
|
|
2010
|
+
_context31.prev = 18;
|
|
1938
2011
|
this.store.isLoading = false;
|
|
1939
|
-
return
|
|
2012
|
+
return _context31.finish(18);
|
|
1940
2013
|
case 21:
|
|
1941
2014
|
case "end":
|
|
1942
|
-
return
|
|
2015
|
+
return _context31.stop();
|
|
1943
2016
|
}
|
|
1944
|
-
},
|
|
2017
|
+
}, _callee31, this, [[0, 14, 18, 21]]);
|
|
1945
2018
|
}));
|
|
1946
|
-
function sendPasswordResetSms(
|
|
2019
|
+
function sendPasswordResetSms(_x28) {
|
|
1947
2020
|
return _sendPasswordResetSms.apply(this, arguments);
|
|
1948
2021
|
}
|
|
1949
2022
|
return sendPasswordResetSms;
|
|
@@ -2027,11 +2100,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2027
2100
|
}, {
|
|
2028
2101
|
key: "initFacebookSDK",
|
|
2029
2102
|
value: (function () {
|
|
2030
|
-
var _initFacebookSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2031
|
-
return _regeneratorRuntime().wrap(function
|
|
2032
|
-
while (1) switch (
|
|
2103
|
+
var _initFacebookSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(token) {
|
|
2104
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2105
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2033
2106
|
case 0:
|
|
2034
|
-
return
|
|
2107
|
+
return _context32.abrupt("return", new Promise(function (resolve, reject) {
|
|
2035
2108
|
if (typeof window === 'undefined') {
|
|
2036
2109
|
reject(new Error('Facebook SDK 只能在浏览器环境中使用'));
|
|
2037
2110
|
return;
|
|
@@ -2065,11 +2138,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2065
2138
|
}));
|
|
2066
2139
|
case 1:
|
|
2067
2140
|
case "end":
|
|
2068
|
-
return
|
|
2141
|
+
return _context32.stop();
|
|
2069
2142
|
}
|
|
2070
|
-
},
|
|
2143
|
+
}, _callee32);
|
|
2071
2144
|
}));
|
|
2072
|
-
function initFacebookSDK(
|
|
2145
|
+
function initFacebookSDK(_x29) {
|
|
2073
2146
|
return _initFacebookSDK.apply(this, arguments);
|
|
2074
2147
|
}
|
|
2075
2148
|
return initFacebookSDK;
|
|
@@ -2081,11 +2154,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2081
2154
|
}, {
|
|
2082
2155
|
key: "initAppleSDK",
|
|
2083
2156
|
value: (function () {
|
|
2084
|
-
var _initAppleSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2085
|
-
return _regeneratorRuntime().wrap(function
|
|
2086
|
-
while (1) switch (
|
|
2157
|
+
var _initAppleSDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2158
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2159
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2087
2160
|
case 0:
|
|
2088
|
-
return
|
|
2161
|
+
return _context33.abrupt("return", new Promise(function (resolve, reject) {
|
|
2089
2162
|
if (typeof window === 'undefined') {
|
|
2090
2163
|
reject(new Error('Apple SDK 只能在浏览器环境中使用'));
|
|
2091
2164
|
return;
|
|
@@ -2120,9 +2193,9 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2120
2193
|
}));
|
|
2121
2194
|
case 1:
|
|
2122
2195
|
case "end":
|
|
2123
|
-
return
|
|
2196
|
+
return _context33.stop();
|
|
2124
2197
|
}
|
|
2125
|
-
},
|
|
2198
|
+
}, _callee33);
|
|
2126
2199
|
}));
|
|
2127
2200
|
function initAppleSDK() {
|
|
2128
2201
|
return _initAppleSDK.apply(this, arguments);
|
|
@@ -2136,51 +2209,51 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2136
2209
|
}, {
|
|
2137
2210
|
key: "loginWithFacebook",
|
|
2138
2211
|
value: (function () {
|
|
2139
|
-
var _loginWithFacebook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2212
|
+
var _loginWithFacebook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(token) {
|
|
2140
2213
|
var _this2 = this;
|
|
2141
|
-
return _regeneratorRuntime().wrap(function
|
|
2142
|
-
while (1) switch (
|
|
2214
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2215
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2143
2216
|
case 0:
|
|
2144
|
-
|
|
2217
|
+
_context35.next = 2;
|
|
2145
2218
|
return this.initFacebookSDK(token);
|
|
2146
2219
|
case 2:
|
|
2147
|
-
return
|
|
2220
|
+
return _context35.abrupt("return", new Promise(function (resolve, reject) {
|
|
2148
2221
|
window.FB.login( /*#__PURE__*/function () {
|
|
2149
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2222
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(response) {
|
|
2150
2223
|
var result;
|
|
2151
|
-
return _regeneratorRuntime().wrap(function
|
|
2152
|
-
while (1) switch (
|
|
2224
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2225
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2153
2226
|
case 0:
|
|
2154
2227
|
if (!response.authResponse) {
|
|
2155
|
-
|
|
2228
|
+
_context34.next = 13;
|
|
2156
2229
|
break;
|
|
2157
2230
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2231
|
+
_context34.prev = 1;
|
|
2232
|
+
_context34.next = 4;
|
|
2160
2233
|
return _this2.apiCaller.call('facebookLogin', {
|
|
2161
2234
|
token: response.authResponse.accessToken
|
|
2162
2235
|
});
|
|
2163
2236
|
case 4:
|
|
2164
|
-
result =
|
|
2237
|
+
result = _context34.sent;
|
|
2165
2238
|
resolve(result);
|
|
2166
|
-
|
|
2239
|
+
_context34.next = 11;
|
|
2167
2240
|
break;
|
|
2168
2241
|
case 8:
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
reject(
|
|
2242
|
+
_context34.prev = 8;
|
|
2243
|
+
_context34.t0 = _context34["catch"](1);
|
|
2244
|
+
reject(_context34.t0);
|
|
2172
2245
|
case 11:
|
|
2173
|
-
|
|
2246
|
+
_context34.next = 14;
|
|
2174
2247
|
break;
|
|
2175
2248
|
case 13:
|
|
2176
2249
|
reject(new Error('facebook_login_cancel'));
|
|
2177
2250
|
case 14:
|
|
2178
2251
|
case "end":
|
|
2179
|
-
return
|
|
2252
|
+
return _context34.stop();
|
|
2180
2253
|
}
|
|
2181
|
-
},
|
|
2254
|
+
}, _callee34, null, [[1, 8]]);
|
|
2182
2255
|
}));
|
|
2183
|
-
return function (
|
|
2256
|
+
return function (_x31) {
|
|
2184
2257
|
return _ref.apply(this, arguments);
|
|
2185
2258
|
};
|
|
2186
2259
|
}(), {
|
|
@@ -2189,11 +2262,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2189
2262
|
}));
|
|
2190
2263
|
case 3:
|
|
2191
2264
|
case "end":
|
|
2192
|
-
return
|
|
2265
|
+
return _context35.stop();
|
|
2193
2266
|
}
|
|
2194
|
-
},
|
|
2267
|
+
}, _callee35, this);
|
|
2195
2268
|
}));
|
|
2196
|
-
function loginWithFacebook(
|
|
2269
|
+
function loginWithFacebook(_x30) {
|
|
2197
2270
|
return _loginWithFacebook.apply(this, arguments);
|
|
2198
2271
|
}
|
|
2199
2272
|
return loginWithFacebook;
|
|
@@ -2205,15 +2278,15 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2205
2278
|
}, {
|
|
2206
2279
|
key: "loginWithApple",
|
|
2207
2280
|
value: (function () {
|
|
2208
|
-
var _loginWithApple = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2281
|
+
var _loginWithApple = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(token) {
|
|
2209
2282
|
var _this3 = this;
|
|
2210
|
-
return _regeneratorRuntime().wrap(function
|
|
2211
|
-
while (1) switch (
|
|
2283
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2284
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2212
2285
|
case 0:
|
|
2213
|
-
|
|
2286
|
+
_context37.next = 2;
|
|
2214
2287
|
return this.initAppleSDK();
|
|
2215
2288
|
case 2:
|
|
2216
|
-
return
|
|
2289
|
+
return _context37.abrupt("return", new Promise(function (resolve, reject) {
|
|
2217
2290
|
try {
|
|
2218
2291
|
var _AppleID, _AppleID2;
|
|
2219
2292
|
// 动态创建 Apple 登录按钮元素
|
|
@@ -2249,12 +2322,12 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2249
2322
|
// 直接调用 Apple ID 登录,并处理 Promise
|
|
2250
2323
|
if ((_AppleID2 = window.AppleID) !== null && _AppleID2 !== void 0 && (_AppleID2 = _AppleID2.auth) !== null && _AppleID2 !== void 0 && _AppleID2.signIn) {
|
|
2251
2324
|
window.AppleID.auth.signIn().then( /*#__PURE__*/function () {
|
|
2252
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2325
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(authResult) {
|
|
2253
2326
|
var _authResult$authoriza, _authResult$authoriza2, authorizationCode, identityToken, result;
|
|
2254
|
-
return _regeneratorRuntime().wrap(function
|
|
2255
|
-
while (1) switch (
|
|
2327
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2328
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2256
2329
|
case 0:
|
|
2257
|
-
|
|
2330
|
+
_context36.prev = 0;
|
|
2258
2331
|
// 清理临时元素
|
|
2259
2332
|
if (document.body.contains(appleSignInDiv)) {
|
|
2260
2333
|
document.body.removeChild(appleSignInDiv);
|
|
@@ -2263,26 +2336,26 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2263
2336
|
// 获取授权码或令牌
|
|
2264
2337
|
authorizationCode = (_authResult$authoriza = authResult.authorization) === null || _authResult$authoriza === void 0 ? void 0 : _authResult$authoriza.code;
|
|
2265
2338
|
identityToken = (_authResult$authoriza2 = authResult.authorization) === null || _authResult$authoriza2 === void 0 ? void 0 : _authResult$authoriza2.id_token; // 使用授权码或身份令牌调用后端接口
|
|
2266
|
-
|
|
2339
|
+
_context36.next = 6;
|
|
2267
2340
|
return _this3.apiCaller.call('appleLogin', {
|
|
2268
2341
|
token: authorizationCode || identityToken
|
|
2269
2342
|
});
|
|
2270
2343
|
case 6:
|
|
2271
|
-
result =
|
|
2344
|
+
result = _context36.sent;
|
|
2272
2345
|
resolve(result);
|
|
2273
|
-
|
|
2346
|
+
_context36.next = 13;
|
|
2274
2347
|
break;
|
|
2275
2348
|
case 10:
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
reject(
|
|
2349
|
+
_context36.prev = 10;
|
|
2350
|
+
_context36.t0 = _context36["catch"](0);
|
|
2351
|
+
reject(_context36.t0);
|
|
2279
2352
|
case 13:
|
|
2280
2353
|
case "end":
|
|
2281
|
-
return
|
|
2354
|
+
return _context36.stop();
|
|
2282
2355
|
}
|
|
2283
|
-
},
|
|
2356
|
+
}, _callee36, null, [[0, 10]]);
|
|
2284
2357
|
}));
|
|
2285
|
-
return function (
|
|
2358
|
+
return function (_x33) {
|
|
2286
2359
|
return _ref2.apply(this, arguments);
|
|
2287
2360
|
};
|
|
2288
2361
|
}()).catch(function (error) {
|
|
@@ -2301,11 +2374,11 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2301
2374
|
}));
|
|
2302
2375
|
case 3:
|
|
2303
2376
|
case "end":
|
|
2304
|
-
return
|
|
2377
|
+
return _context37.stop();
|
|
2305
2378
|
}
|
|
2306
|
-
},
|
|
2379
|
+
}, _callee37, this);
|
|
2307
2380
|
}));
|
|
2308
|
-
function loginWithApple(
|
|
2381
|
+
function loginWithApple(_x32) {
|
|
2309
2382
|
return _loginWithApple.apply(this, arguments);
|
|
2310
2383
|
}
|
|
2311
2384
|
return loginWithApple;
|
|
@@ -2344,44 +2417,44 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2344
2417
|
}, {
|
|
2345
2418
|
key: "getCountries",
|
|
2346
2419
|
value: (function () {
|
|
2347
|
-
var _getCountries = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2420
|
+
var _getCountries = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2348
2421
|
var response;
|
|
2349
|
-
return _regeneratorRuntime().wrap(function
|
|
2350
|
-
while (1) switch (
|
|
2422
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2423
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2351
2424
|
case 0:
|
|
2352
|
-
|
|
2425
|
+
_context38.prev = 0;
|
|
2353
2426
|
this.store.isLoading = true;
|
|
2354
2427
|
this.store.error = null;
|
|
2355
|
-
|
|
2428
|
+
_context38.next = 5;
|
|
2356
2429
|
return this.apiCaller.call('getCountries');
|
|
2357
2430
|
case 5:
|
|
2358
|
-
response =
|
|
2431
|
+
response = _context38.sent;
|
|
2359
2432
|
if (!(response.status && response.data)) {
|
|
2360
|
-
|
|
2433
|
+
_context38.next = 10;
|
|
2361
2434
|
break;
|
|
2362
2435
|
}
|
|
2363
|
-
return
|
|
2436
|
+
return _context38.abrupt("return", response.data);
|
|
2364
2437
|
case 10:
|
|
2365
2438
|
this.store.error = response.message || '获取国家区号失败';
|
|
2366
2439
|
throw new Error(this.store.error);
|
|
2367
2440
|
case 12:
|
|
2368
|
-
|
|
2441
|
+
_context38.next = 19;
|
|
2369
2442
|
break;
|
|
2370
2443
|
case 14:
|
|
2371
|
-
|
|
2372
|
-
|
|
2444
|
+
_context38.prev = 14;
|
|
2445
|
+
_context38.t0 = _context38["catch"](0);
|
|
2373
2446
|
this.store.error = '获取国家区号失败';
|
|
2374
|
-
console.error('[RegisterAndLogin] 获取国家区号失败:',
|
|
2375
|
-
throw
|
|
2447
|
+
console.error('[RegisterAndLogin] 获取国家区号失败:', _context38.t0);
|
|
2448
|
+
throw _context38.t0;
|
|
2376
2449
|
case 19:
|
|
2377
|
-
|
|
2450
|
+
_context38.prev = 19;
|
|
2378
2451
|
this.store.isLoading = false;
|
|
2379
|
-
return
|
|
2452
|
+
return _context38.finish(19);
|
|
2380
2453
|
case 22:
|
|
2381
2454
|
case "end":
|
|
2382
|
-
return
|
|
2455
|
+
return _context38.stop();
|
|
2383
2456
|
}
|
|
2384
|
-
},
|
|
2457
|
+
}, _callee38, this, [[0, 14, 19, 22]]);
|
|
2385
2458
|
}));
|
|
2386
2459
|
function getCountries() {
|
|
2387
2460
|
return _getCountries.apply(this, arguments);
|
|
@@ -2391,19 +2464,19 @@ export var RegisterAndLoginImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2391
2464
|
}, {
|
|
2392
2465
|
key: "destroy",
|
|
2393
2466
|
value: function () {
|
|
2394
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2395
|
-
return _regeneratorRuntime().wrap(function
|
|
2396
|
-
while (1) switch (
|
|
2467
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
2468
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2469
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2397
2470
|
case 0:
|
|
2398
|
-
|
|
2471
|
+
_context39.next = 2;
|
|
2399
2472
|
return this.core.effects.emit(RegisterAndLoginHooks.onDestroy, {});
|
|
2400
2473
|
case 2:
|
|
2401
2474
|
console.log('[RegisterAndLogin] 已销毁');
|
|
2402
2475
|
case 3:
|
|
2403
2476
|
case "end":
|
|
2404
|
-
return
|
|
2477
|
+
return _context39.stop();
|
|
2405
2478
|
}
|
|
2406
|
-
},
|
|
2479
|
+
}, _callee39, this);
|
|
2407
2480
|
}));
|
|
2408
2481
|
function destroy() {
|
|
2409
2482
|
return _destroy.apply(this, arguments);
|