@iankibetsh/shframework 1.1.0 → 1.1.2

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.
@@ -1,4 +1,36 @@
1
1
 
2
+ .sh-phone{
3
+ display: flex;
4
+ width: 100%;
5
+ align-items: center;
6
+ padding: 0 0.25rem;
7
+ }
8
+ .phone-country{
9
+ width: 2rem;
10
+ border: none;
11
+ align-self: center;
12
+ outline: none !important;
13
+ padding: 0.4rem;
14
+ border-right: 1px solid #0003;
15
+ }
16
+ .phone-number{
17
+ width: calc(100% - 2.2rem);
18
+ border: none;
19
+ align-self: center;
20
+ outline: none;
21
+ margin-bottom: 0;
22
+ padding: 0.4rem;
23
+ }
24
+ .sh-phone img{
25
+ padding: 0.125rem;
26
+ width: 2rem;
27
+ height: 2rem;
28
+ }
29
+ .phone-number::placeholder{
30
+ font-weight: 300;
31
+ opacity: 0.5;
32
+ }
33
+
2
34
  .colored-toast.swal2-icon-success {
3
35
  background-color: #a5dc86 !important;
4
36
  }
@@ -31,36 +63,19 @@
31
63
  color: white;
32
64
  }
33
65
 
34
- .sh-phone{
35
- display: flex;
36
- width: 100%;
37
- align-items: center;
38
- padding: 0 0.25rem;
39
- }
40
- .phone-country{
41
- width: 2rem;
42
- border: none;
43
- align-self: center;
44
- outline: none !important;
45
- padding: 0.4rem;
46
- border-right: 1px solid #0003;
66
+ .sh-selected-item{
67
+ line-height: unset!important;
47
68
  }
48
- .phone-number{
49
- width: calc(100% - 2.2rem);
50
- border: none;
51
- align-self: center;
52
- outline: none;
53
- margin-bottom: 0;
54
- padding: 0.4rem;
69
+ .sh-suggestion-input{
70
+ padding: 0.375rem 0.75rem;
55
71
  }
56
- .sh-phone img{
57
- padding: 0.125rem;
58
- width: 2rem;
59
- height: 2rem;
72
+ .sh-suggest{
73
+ margin-bottom: 1rem;
60
74
  }
61
- .phone-number::placeholder{
62
- font-weight: 300;
63
- opacity: 0.5;
75
+ .sh-suggest-control::after{
76
+ margin-top: auto;
77
+ margin-bottom: auto;
78
+ margin-right: 0.255em;
64
79
  }
65
80
 
66
81
  :root {
@@ -84,21 +99,6 @@
84
99
  }
85
100
  }
86
101
 
87
- .sh-selected-item{
88
- line-height: unset!important;
89
- }
90
- .sh-suggestion-input{
91
- padding: 0.375rem 0.75rem;
92
- }
93
- .sh-suggest{
94
- margin-bottom: 1rem;
95
- }
96
- .sh-suggest-control::after{
97
- margin-top: auto;
98
- margin-bottom: auto;
99
- margin-right: 0.255em;
100
- }
101
-
102
102
  .sh-forgot-link, .sh-register-link{
103
103
  cursor: pointer;
104
104
  }
package/dist/library.js CHANGED
@@ -39,30 +39,59 @@ var ShStorage = {
39
39
  removeItem
40
40
  };
41
41
 
42
+ function logoutUser(){
43
+ // let logoutUrl = inject()
44
+ const logoutApiEndpoint = vue.inject('logoutApiEndpoint','auth/logout');
45
+ shApis.doPost(logoutApiEndpoint).then(res=>{
46
+ ShStorage.removeItem('access_token');
47
+ ShStorage.removeItem('user');
48
+ // const loginUrl = inject('loginUrl','/login')
49
+ window.location.href = '/login';
50
+ }).catch(ex=>{
51
+ vue.inject('loginUrl','/login');
52
+ ShStorage.removeItem('access_token');
53
+ ShStorage.removeItem('user');
54
+ window.location.href = '/login';
55
+ });
56
+ JSON.parse(ShStorage.getItem('user'));
57
+ }
42
58
  const checkSession = function (isCheking) {
43
59
  let timeout = vue.inject('sessionTimeout');
44
60
  if(!timeout){
45
61
  timeout = 30;
62
+ } else {
63
+ timeout = parseFloat(timeout);
46
64
  }
47
- const sessionStart = ShStorage.getItem('session_start');
48
- const started = moment__default["default"](sessionStart);
49
- if(!sessionStart){
50
- ShStorage.removeItem('access_token');
51
- ShStorage.removeItem('user');
52
- return false
53
- }
54
- const pastMinutes = moment__default["default"]().diff(started, 'minutes');
55
- if(pastMinutes >= timeout) {
56
- ShStorage.removeItem('user');
57
- ShStorage.removeItem('access_token');
58
- return false
65
+ if(window.shLogoutTimeout){
66
+ clearTimeout(window.shLogoutTimeout);
59
67
  }
60
- if (isCheking) {
61
- return true
68
+
69
+ if(ShStorage.getItem('access_token')){
70
+ const timeOutSession = setTimeout(()=>{
71
+ logoutUser();
72
+ }, timeout * 60 * 1000);
73
+ window.shLogoutTimeout = timeOutSession;
62
74
  }
63
- const timeNow = moment__default["default"]().toISOString();
64
- ShStorage.setItem('session_start', timeNow);
65
- return true
75
+
76
+ // const sessionStart = ShStorage.getItem('session_start')
77
+ // const started = moment(sessionStart)
78
+ // if(!sessionStart){
79
+ // ShStorage.removeItem('access_token')
80
+ // ShStorage.removeItem('user')
81
+ // return false
82
+ // }
83
+ // const pastMinutes = moment().diff(started, 'minutes')
84
+ // if(pastMinutes >= timeout) {
85
+ // ShStorage.removeItem('user')
86
+ // ShStorage.removeItem('access_token')
87
+ // return false
88
+ // }
89
+ // if (isCheking) {
90
+ // return true
91
+ // }
92
+ // const timeNow = moment().toISOString()
93
+ // ShStorage.setItem('session_start', timeNow)
94
+ // return true
66
95
  };
67
96
 
68
97
  let apiUrl = undefined.VITE_APP_API_URL;
@@ -4807,6 +4836,8 @@ const ShFrontend = {
4807
4836
  const registerEndpoint = options.registerEndpoint ?? 'auth/register';
4808
4837
  const registerTitle = options.registerTitle ?? 'Create a new account';
4809
4838
  const registerSubTitle = options.registerSubTitle ?? `It's quick and easy`;
4839
+ const logoutApiEndpoint = options.logoutApiEndpoint ?? `auth/logout`;
4840
+ const loginUrl = options.loginUrl ?? `/login`;
4810
4841
  const redirectLogin = options.redirectLogin ?? `/`;
4811
4842
  const redirectRegister = options.redirectRegister ?? `/`;
4812
4843
  const registrationFields = options.registrationFields ?? ['name','email','phone','password','password_confirmation'];
@@ -4818,6 +4849,8 @@ const ShFrontend = {
4818
4849
  app.provide('registerSubTitle', registerSubTitle);
4819
4850
  app.provide('redirectLogin', redirectLogin);
4820
4851
  app.provide('redirectRegister', redirectRegister);
4852
+ app.provide('logoutApiEndpoint', logoutApiEndpoint);
4853
+ app.provide('loginUrl', loginUrl);
4821
4854
  window.swalPosition = swalPosition;
4822
4855
  if(options.router) {
4823
4856
  options.router.addRoute({
package/dist/library.mjs CHANGED
@@ -27,30 +27,59 @@ var ShStorage = {
27
27
  removeItem
28
28
  };
29
29
 
30
+ function logoutUser(){
31
+ // let logoutUrl = inject()
32
+ const logoutApiEndpoint = inject('logoutApiEndpoint','auth/logout');
33
+ shApis.doPost(logoutApiEndpoint).then(res=>{
34
+ ShStorage.removeItem('access_token');
35
+ ShStorage.removeItem('user');
36
+ // const loginUrl = inject('loginUrl','/login')
37
+ window.location.href = '/login';
38
+ }).catch(ex=>{
39
+ inject('loginUrl','/login');
40
+ ShStorage.removeItem('access_token');
41
+ ShStorage.removeItem('user');
42
+ window.location.href = '/login';
43
+ });
44
+ JSON.parse(ShStorage.getItem('user'));
45
+ }
30
46
  const checkSession = function (isCheking) {
31
47
  let timeout = inject('sessionTimeout');
32
48
  if(!timeout){
33
49
  timeout = 30;
50
+ } else {
51
+ timeout = parseFloat(timeout);
34
52
  }
35
- const sessionStart = ShStorage.getItem('session_start');
36
- const started = moment(sessionStart);
37
- if(!sessionStart){
38
- ShStorage.removeItem('access_token');
39
- ShStorage.removeItem('user');
40
- return false
41
- }
42
- const pastMinutes = moment().diff(started, 'minutes');
43
- if(pastMinutes >= timeout) {
44
- ShStorage.removeItem('user');
45
- ShStorage.removeItem('access_token');
46
- return false
53
+ if(window.shLogoutTimeout){
54
+ clearTimeout(window.shLogoutTimeout);
47
55
  }
48
- if (isCheking) {
49
- return true
56
+
57
+ if(ShStorage.getItem('access_token')){
58
+ const timeOutSession = setTimeout(()=>{
59
+ logoutUser();
60
+ }, timeout * 60 * 1000);
61
+ window.shLogoutTimeout = timeOutSession;
50
62
  }
51
- const timeNow = moment().toISOString();
52
- ShStorage.setItem('session_start', timeNow);
53
- return true
63
+
64
+ // const sessionStart = ShStorage.getItem('session_start')
65
+ // const started = moment(sessionStart)
66
+ // if(!sessionStart){
67
+ // ShStorage.removeItem('access_token')
68
+ // ShStorage.removeItem('user')
69
+ // return false
70
+ // }
71
+ // const pastMinutes = moment().diff(started, 'minutes')
72
+ // if(pastMinutes >= timeout) {
73
+ // ShStorage.removeItem('user')
74
+ // ShStorage.removeItem('access_token')
75
+ // return false
76
+ // }
77
+ // if (isCheking) {
78
+ // return true
79
+ // }
80
+ // const timeNow = moment().toISOString()
81
+ // ShStorage.setItem('session_start', timeNow)
82
+ // return true
54
83
  };
55
84
 
56
85
  let apiUrl = import.meta.env.VITE_APP_API_URL;
@@ -4795,6 +4824,8 @@ const ShFrontend = {
4795
4824
  const registerEndpoint = options.registerEndpoint ?? 'auth/register';
4796
4825
  const registerTitle = options.registerTitle ?? 'Create a new account';
4797
4826
  const registerSubTitle = options.registerSubTitle ?? `It's quick and easy`;
4827
+ const logoutApiEndpoint = options.logoutApiEndpoint ?? `auth/logout`;
4828
+ const loginUrl = options.loginUrl ?? `/login`;
4798
4829
  const redirectLogin = options.redirectLogin ?? `/`;
4799
4830
  const redirectRegister = options.redirectRegister ?? `/`;
4800
4831
  const registrationFields = options.registrationFields ?? ['name','email','phone','password','password_confirmation'];
@@ -4806,6 +4837,8 @@ const ShFrontend = {
4806
4837
  app.provide('registerSubTitle', registerSubTitle);
4807
4838
  app.provide('redirectLogin', redirectLogin);
4808
4839
  app.provide('redirectRegister', redirectRegister);
4840
+ app.provide('logoutApiEndpoint', logoutApiEndpoint);
4841
+ app.provide('loginUrl', loginUrl);
4809
4842
  window.swalPosition = swalPosition;
4810
4843
  if(options.router) {
4811
4844
  options.router.addRoute({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",