@iankibetsh/shframework 1.1.0 → 1.1.3

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.
@@ -63,6 +63,25 @@
63
63
  opacity: 0.5;
64
64
  }
65
65
 
66
+ .sh-selected-item{
67
+ line-height: unset!important;
68
+ }
69
+ .sh-suggestion-input{
70
+ padding: 0.375rem 0.75rem;
71
+ }
72
+ .sh-suggest{
73
+ margin-bottom: 1rem;
74
+ }
75
+ .sh-suggest-control::after{
76
+ margin-top: auto;
77
+ margin-bottom: auto;
78
+ margin-right: 0.255em;
79
+ }
80
+
81
+ .sh-forgot-link, .sh-register-link{
82
+ cursor: pointer;
83
+ }
84
+
66
85
  :root {
67
86
  --ck-z-default: 10555 !important;
68
87
  --ck-z-modal: calc(var(--ck-z-default) + 999) !important;
@@ -83,22 +102,3 @@
83
102
  width: 100% !important;
84
103
  }
85
104
  }
86
-
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
- .sh-forgot-link, .sh-register-link{
103
- cursor: pointer;
104
- }
package/dist/library.js CHANGED
@@ -39,30 +39,61 @@ 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 ?? 'auth/logout').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
+ if(ShStorage.getItem('access_token')){
72
+ logoutUser();
73
+ }
74
+ }, timeout * 60 * 1000);
75
+ window.shLogoutTimeout = timeOutSession;
62
76
  }
63
- const timeNow = moment__default["default"]().toISOString();
64
- ShStorage.setItem('session_start', timeNow);
65
- return true
77
+
78
+ // const sessionStart = ShStorage.getItem('session_start')
79
+ // const started = moment(sessionStart)
80
+ // if(!sessionStart){
81
+ // ShStorage.removeItem('access_token')
82
+ // ShStorage.removeItem('user')
83
+ // return false
84
+ // }
85
+ // const pastMinutes = moment().diff(started, 'minutes')
86
+ // if(pastMinutes >= timeout) {
87
+ // ShStorage.removeItem('user')
88
+ // ShStorage.removeItem('access_token')
89
+ // return false
90
+ // }
91
+ // if (isCheking) {
92
+ // return true
93
+ // }
94
+ // const timeNow = moment().toISOString()
95
+ // ShStorage.setItem('session_start', timeNow)
96
+ // return true
66
97
  };
67
98
 
68
99
  let apiUrl = undefined.VITE_APP_API_URL;
@@ -4807,6 +4838,8 @@ const ShFrontend = {
4807
4838
  const registerEndpoint = options.registerEndpoint ?? 'auth/register';
4808
4839
  const registerTitle = options.registerTitle ?? 'Create a new account';
4809
4840
  const registerSubTitle = options.registerSubTitle ?? `It's quick and easy`;
4841
+ const logoutApiEndpoint = options.logoutApiEndpoint ?? `auth/logout`;
4842
+ const loginUrl = options.loginUrl ?? `/login`;
4810
4843
  const redirectLogin = options.redirectLogin ?? `/`;
4811
4844
  const redirectRegister = options.redirectRegister ?? `/`;
4812
4845
  const registrationFields = options.registrationFields ?? ['name','email','phone','password','password_confirmation'];
@@ -4818,6 +4851,8 @@ const ShFrontend = {
4818
4851
  app.provide('registerSubTitle', registerSubTitle);
4819
4852
  app.provide('redirectLogin', redirectLogin);
4820
4853
  app.provide('redirectRegister', redirectRegister);
4854
+ app.provide('logoutApiEndpoint', logoutApiEndpoint);
4855
+ app.provide('loginUrl', loginUrl);
4821
4856
  window.swalPosition = swalPosition;
4822
4857
  if(options.router) {
4823
4858
  options.router.addRoute({
package/dist/library.mjs CHANGED
@@ -27,30 +27,61 @@ 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 ?? 'auth/logout').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
+ if(ShStorage.getItem('access_token')){
60
+ logoutUser();
61
+ }
62
+ }, timeout * 60 * 1000);
63
+ window.shLogoutTimeout = timeOutSession;
50
64
  }
51
- const timeNow = moment().toISOString();
52
- ShStorage.setItem('session_start', timeNow);
53
- return true
65
+
66
+ // const sessionStart = ShStorage.getItem('session_start')
67
+ // const started = moment(sessionStart)
68
+ // if(!sessionStart){
69
+ // ShStorage.removeItem('access_token')
70
+ // ShStorage.removeItem('user')
71
+ // return false
72
+ // }
73
+ // const pastMinutes = moment().diff(started, 'minutes')
74
+ // if(pastMinutes >= timeout) {
75
+ // ShStorage.removeItem('user')
76
+ // ShStorage.removeItem('access_token')
77
+ // return false
78
+ // }
79
+ // if (isCheking) {
80
+ // return true
81
+ // }
82
+ // const timeNow = moment().toISOString()
83
+ // ShStorage.setItem('session_start', timeNow)
84
+ // return true
54
85
  };
55
86
 
56
87
  let apiUrl = import.meta.env.VITE_APP_API_URL;
@@ -4795,6 +4826,8 @@ const ShFrontend = {
4795
4826
  const registerEndpoint = options.registerEndpoint ?? 'auth/register';
4796
4827
  const registerTitle = options.registerTitle ?? 'Create a new account';
4797
4828
  const registerSubTitle = options.registerSubTitle ?? `It's quick and easy`;
4829
+ const logoutApiEndpoint = options.logoutApiEndpoint ?? `auth/logout`;
4830
+ const loginUrl = options.loginUrl ?? `/login`;
4798
4831
  const redirectLogin = options.redirectLogin ?? `/`;
4799
4832
  const redirectRegister = options.redirectRegister ?? `/`;
4800
4833
  const registrationFields = options.registrationFields ?? ['name','email','phone','password','password_confirmation'];
@@ -4806,6 +4839,8 @@ const ShFrontend = {
4806
4839
  app.provide('registerSubTitle', registerSubTitle);
4807
4840
  app.provide('redirectLogin', redirectLogin);
4808
4841
  app.provide('redirectRegister', redirectRegister);
4842
+ app.provide('logoutApiEndpoint', logoutApiEndpoint);
4843
+ app.provide('loginUrl', loginUrl);
4809
4844
  window.swalPosition = swalPosition;
4810
4845
  if(options.router) {
4811
4846
  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.3",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",