@social-mail/social-mail-client 1.2.147 → 1.2.148

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.
Files changed (49) hide show
  1. package/content/json/countries.json +1577 -0
  2. package/dist/admin/AdminAppIndex.pack.js +430 -11
  3. package/dist/admin/AdminAppIndex.pack.js.map +1 -1
  4. package/dist/admin/AdminAppIndex.pack.min.js +45 -4
  5. package/dist/admin/AdminAppIndex.pack.min.js.map +1 -1
  6. package/dist/common/controls/countries/CountrySelect.d.ts +4 -0
  7. package/dist/common/controls/countries/CountrySelect.d.ts.map +1 -0
  8. package/dist/common/controls/countries/CountrySelect.js +49 -0
  9. package/dist/common/controls/countries/CountrySelect.js.map +1 -0
  10. package/dist/common/controls/phone-editor/PhoneEditor.d.ts +5 -0
  11. package/dist/common/controls/phone-editor/PhoneEditor.d.ts.map +1 -0
  12. package/dist/common/controls/phone-editor/PhoneEditor.js +25 -0
  13. package/dist/common/controls/phone-editor/PhoneEditor.js.map +1 -0
  14. package/dist/common/pages/user/forgot/ForgotPassword.d.ts +24 -0
  15. package/dist/common/pages/user/forgot/ForgotPassword.d.ts.map +1 -0
  16. package/dist/common/pages/user/forgot/ForgotPassword.js +219 -0
  17. package/dist/common/pages/user/forgot/ForgotPassword.js.map +1 -0
  18. package/dist/common/pages/user/login/LoginPage.d.ts +1 -0
  19. package/dist/common/pages/user/login/LoginPage.d.ts.map +1 -1
  20. package/dist/common/pages/user/login/LoginPage.js +67 -6
  21. package/dist/common/pages/user/login/LoginPage.js.map +1 -1
  22. package/dist/public/channel/ChannelView.pack.js +8 -4
  23. package/dist/public/channel/ChannelView.pack.js.map +1 -1
  24. package/dist/public/channel/ChannelView.pack.min.js +3 -3
  25. package/dist/public/channel/ChannelView.pack.min.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/web/AppIndex.pack.js +430 -11
  28. package/dist/web/AppIndex.pack.js.map +1 -1
  29. package/dist/web/AppIndex.pack.min.js +45 -4
  30. package/dist/web/AppIndex.pack.min.js.map +1 -1
  31. package/node_modules/@web-atoms/core/dist/services/FetchBuilder.d.ts.map +1 -1
  32. package/node_modules/@web-atoms/core/dist/services/FetchBuilder.js +2 -1
  33. package/node_modules/@web-atoms/core/dist/services/FetchBuilder.js.map +1 -1
  34. package/node_modules/@web-atoms/core/dist/services/http/JsonError.d.ts.map +1 -1
  35. package/node_modules/@web-atoms/core/dist/services/http/JsonError.js +5 -2
  36. package/node_modules/@web-atoms/core/dist/services/http/JsonError.js.map +1 -1
  37. package/node_modules/@web-atoms/core/dist/tsconfig.tsbuildinfo +1 -1
  38. package/node_modules/@web-atoms/core/package.json +1 -1
  39. package/node_modules/@web-atoms/core/src/services/FetchBuilder.ts +5 -1
  40. package/node_modules/@web-atoms/core/src/services/http/JsonError.ts +3 -2
  41. package/node_modules/@web-atoms/module-loader/package.json +1 -1
  42. package/node_modules/@web-atoms/module-loader/umd/src/AmdLoader.ts +1 -1
  43. package/node_modules/@web-atoms/module-loader/umd.js +1 -1
  44. package/node_modules/@web-atoms/module-loader/umd.js.map +1 -1
  45. package/package.json +3 -3
  46. package/src/common/controls/countries/CountrySelect.tsx +39 -0
  47. package/src/common/controls/phone-editor/PhoneEditor.tsx +12 -0
  48. package/src/common/pages/user/forgot/ForgotPassword.tsx +229 -0
  49. package/src/common/pages/user/login/LoginPage.tsx +60 -4
@@ -0,0 +1,229 @@
1
+ import Bind from "@web-atoms/core/dist/core/Bind";
2
+ import XNode from "@web-atoms/core/dist/core/XNode";
3
+ import styled from "@web-atoms/core/dist/style/styled";
4
+ import Form from "@web-atoms/web-controls/dist/basic/Form";
5
+ import FormField from "@web-atoms/web-controls/dist/basic/FormField";
6
+ import { ContentPage } from "@web-atoms/web-controls/dist/mobile-app/MobileApp";
7
+ import { CountrySelect, formatForCountry, isdForCountry } from "../../../controls/countries/CountrySelect";
8
+ import MaskedInput from "@web-atoms/web-controls/dist/basic/MaskedInput";
9
+ import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder";
10
+ import Action from "@web-atoms/core/dist/view-model/Action";
11
+ import PopupService from "@web-atoms/core/dist/web/services/PopupService";
12
+ import PasswordBox from "@web-atoms/web-controls/dist/basic/PasswordBox";
13
+
14
+ const css = styled.css `
15
+ & [data-border=frame] {
16
+ padding: 10px;
17
+ border-radius: 10px;
18
+ gap: 10px;
19
+
20
+ & h3 {
21
+ margin-block-start: 20px;
22
+ margin-block-end: 20px;
23
+ }
24
+
25
+ & input {
26
+ outline: none;
27
+ border: none;
28
+ border-bottom: solid 1px #80808080;
29
+ min-width: 250px;
30
+ }
31
+ }
32
+ `.installLocal();
33
+
34
+ interface IVerification {
35
+ id?: string;
36
+ code?: string;
37
+ verified?: string;
38
+ }
39
+
40
+ export default class ForgotPassword extends ContentPage {
41
+
42
+ model: {
43
+ username: string;
44
+ password: string;
45
+ passwordAgain: string;
46
+ phoneNumber: string;
47
+ country: string;
48
+ phoneNumberText: string;
49
+ captcha: IVerification;
50
+ phone: IVerification;
51
+ } = {
52
+ username: "",
53
+ password: "",
54
+ passwordAgain: "",
55
+ phoneNumber: "",
56
+ country: "US",
57
+ phoneNumberText: "",
58
+ phone: {
59
+ code: ""
60
+ },
61
+ captcha: {
62
+ code: ""
63
+ }
64
+ };
65
+
66
+ async init() {
67
+
68
+ this.hideToolbar = true;
69
+
70
+ this.title = "Reset Password";
71
+
72
+ const { id } = await FetchBuilder.put("/api/users/captcha").responseAsJson<{ id }>();
73
+ this.model.captcha.id = id;
74
+
75
+
76
+ this.render(<div class={css}>
77
+ <div data-layout="center-all">
78
+ <Form data-border="frame">
79
+ <h3>
80
+ To reset password, enter following.
81
+ </h3>
82
+
83
+ <FormField label="Username">
84
+ <input
85
+ autofocus={true}
86
+ value={Bind.twoWaysImmediate(() => this.model.username)}/>
87
+ </FormField>
88
+
89
+ <FormField label="Phone Number">
90
+ <div data-layout="row">
91
+ <CountrySelect
92
+ value={Bind.twoWaysImmediate(() => this.model.country)}
93
+ />
94
+ <MaskedInput
95
+ data-mask={Bind.oneWayAsync(() => formatForCountry(this.model.country))}
96
+ value={Bind.twoWaysImmediate(() => this.model.phoneNumberText)}
97
+ />
98
+ </div>
99
+ </FormField>
100
+
101
+
102
+ <FormField label="Captcha">
103
+ <img src={`/api/users/captcha/${id}`}/>
104
+ </FormField>
105
+ <FormField label="Enter 5 Digit Code">
106
+ <input
107
+ type="tel"
108
+ value={Bind.twoWaysImmediate(() => this.model.captcha.code)}/>
109
+ </FormField>
110
+ <div data-layout="row">
111
+ <button
112
+ data-layout="go-button"
113
+ data-submit-event="ask-code"
114
+ >Next</button>
115
+ </div>
116
+
117
+ </Form>
118
+ </div>
119
+ </div>);
120
+ }
121
+
122
+ @Action({ onEvent: "ask-code"})
123
+ async resetPassword() {
124
+
125
+ const { model } = this;
126
+
127
+ if (model.phone.verified) {
128
+ if (!model.password) {
129
+ throw new Error("Password is required");
130
+ }
131
+ }
132
+
133
+ if (model.password) {
134
+
135
+ if (model.password.length < 7) {
136
+ throw new Error("Password is cannot be less than 7 characters");
137
+ }
138
+
139
+ if (/\s/i.test(model.password)) {
140
+ throw new Error("Password must not any whitespace characters");
141
+ }
142
+
143
+ if (model.passwordAgain !== model.password) {
144
+ throw new Error("Passwords do not match");
145
+ }
146
+ }
147
+
148
+
149
+ const isdCode = await isdForCountry(model.country);
150
+ const phoneNumber = model.phoneNumberText.replace(/[^0-9]/g,"");
151
+ model.phoneNumber = isdCode.startsWith("+") ? isdCode + phoneNumber: `+${isdCode}${phoneNumber}`;
152
+
153
+ const { userID, phone, captcha } = await FetchBuilder.post("/api/users/password/reset/")
154
+ .jsonBody(this.model)
155
+ .responseAsJson<{ phone: IVerification, captcha: IVerification, userID: any }>();
156
+
157
+ if (captcha?.verified) {
158
+ model.captcha.verified = captcha.verified;
159
+ }
160
+
161
+ if (userID) {
162
+ await PopupService.alert({ message: "Password has been reset successully, please login with your new password." });
163
+ location.href = "/";
164
+ return;
165
+ }
166
+
167
+ if(phone.verified) {
168
+ this.model.phone.verified = phone.verified;
169
+ this.askPasswords();
170
+ return;
171
+ }
172
+
173
+ if (phone.id) {
174
+ this.model.phone.id = phone.id;
175
+ }
176
+
177
+ this.askCode();
178
+ }
179
+
180
+ askCode() {
181
+ this.renderer = <div class={css}>
182
+ <div data-layout="center-all">
183
+ <Form data-border="frame">
184
+ <h3>
185
+ Enter verification code.
186
+ </h3>
187
+ <FormField label="Code">
188
+ <input type="tel" value={Bind.twoWaysImmediate(() => this.model.phone.code)}/>
189
+ </FormField>
190
+ <div data-layout="row">
191
+ <button
192
+ data-layout="go-button"
193
+ data-submit-event="ask-code">Next</button>
194
+ </div>
195
+
196
+ </Form>
197
+ </div>
198
+ </div>;
199
+ }
200
+
201
+ askPasswords() {
202
+ this.renderer = <div class={css}>
203
+ <div data-layout="center-all">
204
+ <Form data-border="frame">
205
+ <h3>
206
+ Enter new password.
207
+ </h3>
208
+ <FormField label="Password">
209
+ <PasswordBox
210
+ value={Bind.twoWaysImmediate(() => this.model.password)}
211
+ />
212
+ </FormField>
213
+ <FormField label="Password Again">
214
+ <PasswordBox
215
+ value={Bind.twoWaysImmediate(() => this.model.passwordAgain)}
216
+ />
217
+ </FormField>
218
+ <div data-layout="row">
219
+ <button
220
+ data-layout="go-button"
221
+ data-submit-event="ask-code">Next</button>
222
+ </div>
223
+
224
+ </Form>
225
+ </div>
226
+ </div>;
227
+ }
228
+
229
+ }
@@ -14,6 +14,30 @@ import PasswordStrength from "../../../controls/password/PasswordStrength";
14
14
  import { Validators } from "../../../validators/Validators";
15
15
  import ToggleButtonBar from "@web-atoms/web-controls/dist/basic/ToggleButtonBar";
16
16
  import { SaveIconTextButton } from "../../../controls/buttons/IconButton";
17
+ import styled from "@web-atoms/core/dist/style/styled";
18
+ import PageNavigator from "@web-atoms/web-controls/dist/PageNavigator";
19
+ import ForgotPassword from "../forgot/ForgotPassword";
20
+ import PopupService from "@web-atoms/core/dist/web/services/PopupService";
21
+
22
+ const css = styled.css `
23
+ & [data-border=frame] {
24
+ padding: 10px;
25
+ border-radius: 10px;
26
+ gap: 10px;
27
+
28
+ & h3 {
29
+ margin-block-start: 20px;
30
+ margin-block-end: 20px;
31
+ }
32
+
33
+ & input {
34
+ outline: none;
35
+ border: none;
36
+ border-bottom: solid 1px #80808080;
37
+ min-width: 250px;
38
+ }
39
+ }
40
+ `.installLocal();
17
41
 
18
42
  const authTypes = [{
19
43
  label: "Authenticator (TOTP)",
@@ -37,29 +61,50 @@ export default class LoginPage extends ContentPage {
37
61
  private authType = "totp";
38
62
 
39
63
  async init() {
64
+
65
+ this.footerRenderer = () => <div data-layout="row">
66
+ <a
67
+ target="_blank"
68
+ data-margin-left="auto"
69
+ href="https://socialmail.me">Social Mail</a>
70
+ </div>;
71
+
72
+ this.hideToolbar = true;
73
+
40
74
  this.model = LoginSession.create({});
41
75
  this.model.userName = "";
42
76
  this.model.checkPassword = "";
43
77
  this.model.timeToken = "";
44
78
  this.model.oneTimePassword = "";
45
- this.render(<div>
79
+ this.render(<div class={css}>
46
80
  <div data-layout="center-all">
47
- <Form>
81
+ <Form data-border="frame">
82
+ <h3>
83
+ Sign in to continue
84
+ </h3>
48
85
  <FormField label="Username">
49
- <input value={Bind.twoWaysImmediate(() => this.model.userName)}/>
86
+ <input
87
+ autofocus={true}
88
+ value={Bind.twoWaysImmediate(() => this.model.userName)}/>
50
89
  </FormField>
51
90
  <FormField label="Password">
52
91
  <PasswordBox
53
92
  value={Bind.twoWaysImmediate(() => this.model.checkPassword)}
54
93
  />
55
94
  </FormField>
56
- <div>
95
+ <div data-layout="row">
57
96
  <button
58
97
  data-layout="accent-button"
59
98
  data-submit-event="login"
60
99
  text="Login"
61
100
  />
62
101
  </div>
102
+
103
+ { <div data-layout="row">
104
+ <span
105
+ data-click-event="forgot-password"
106
+ data-layout="link">Forgot password?</span>
107
+ </div>}
63
108
  </Form>
64
109
  </div>
65
110
  </div>);
@@ -143,4 +188,15 @@ export default class LoginPage extends ContentPage {
143
188
 
144
189
  }
145
190
 
191
+ @Action({ onEvent: "forgot-password"})
192
+ async forgotPassword() {
193
+ if (/socialmail\.me/i.test(location.href)) {
194
+ PageNavigator.openPage(ForgotPassword);
195
+ return;
196
+ }
197
+ await PopupService.alert({
198
+ message: "Please contact your administrator"
199
+ });
200
+ }
201
+
146
202
  }