cyclid-ui 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca86e931e0eb566c2bf638de74c388e675222437
4
- data.tar.gz: 26afc5f71cf7f4ade5ae25cc6c57b9babe9dab80
3
+ metadata.gz: cd46e94bf7a619733c91ec752eaebbb95fe350eb
4
+ data.tar.gz: c15070a30d7e592fdfda470fcb7cc5445ca66c17
5
5
  SHA512:
6
- metadata.gz: 106ad7cb054099d963434b127d7dda2cfbedbe9dc66f4fcbc8147456b063534d7d7ea3dc9e56a36bb8dfa446f4a0870bdf267ce500817c8d12e61c33975175c0
7
- data.tar.gz: b56757b82268f45d2774c3e0390798b17ef6f190c34c636e94143ce014fef7686b64bc748501a77bb9d944b6969a0a1a3e7aea45a6ccecde771f586ff350de62
6
+ metadata.gz: 94f096894e5d41acbaf6f061723646e3b5bf8e9a2bbe7f9c48988eca30dd8d1caa6311343ef197a45ed9da279c5ce3380133ea2ec2fbcf299445c81ffe49e92c
7
+ data.tar.gz: eccb3e14ffe05c46f3676d21aa92efd44e0cd3aa84cf6ebe9886340b7f69c79a82899bc402aca5bdf77f1d0cf3711feb687caa50c563c33dcbf76a23878d9115
@@ -88,9 +88,13 @@ module Cyclid
88
88
  use Warden::Manager do |config|
89
89
  config.serialize_into_session(&:username)
90
90
  config.serialize_from_session do |username|
91
- # Animal skins & flint knives...
92
- token = env['rack.request.cookie_hash']['cyclid.token']
93
- Models::User.get(username: username, token: token)
91
+ begin
92
+ # Animal skins & flint knives...
93
+ token = env['rack.request.cookie_hash']['cyclid.token']
94
+ Models::User.get(username: username, token: token)
95
+ rescue
96
+ nil
97
+ end
94
98
  end
95
99
 
96
100
  config.scope_defaults :default,
@@ -113,6 +117,8 @@ module Cyclid
113
117
  user = Models::User.get(username: username, token: token)
114
118
 
115
119
  user.nil? ? fail!('invalid user') : success!(user)
120
+ rescue
121
+ fail!('invalid user')
116
122
  end
117
123
  end
118
124
 
@@ -125,6 +131,7 @@ module Cyclid
125
131
  # it sees the 401 response
126
132
  env['warden'].custom_failure!
127
133
  flash[:login_error] = 'Invalid username or password'
134
+ cookies.delete 'cyclid.token'
128
135
  redirect to '/login'
129
136
  end
130
137
 
@@ -51,8 +51,12 @@ module Cyclid
51
51
 
52
52
  # At this point the user has authenticated successfully; get the user
53
53
  # information; the User model will cache it automatically.
54
- user = Models::User.get(username: username, password: password)
55
- Cyclid.logger.debug "user=#{user.to_hash}"
54
+ begin
55
+ user = Models::User.get(username: username, password: password)
56
+ Cyclid.logger.debug "user=#{user.to_hash}"
57
+ rescue
58
+ halt_with_401
59
+ end
56
60
 
57
61
  # Store the username in the session
58
62
  session[:username] = username
@@ -69,6 +69,9 @@ module Cyclid
69
69
 
70
70
  auth_method = token.nil? ? Client::AUTH_BASIC : Client::AUTH_TOKEN
71
71
 
72
+ # We must have one or the other
73
+ raise 'no password or token' if password.nil? and token.nil?
74
+
72
75
  user_data = nil
73
76
  begin
74
77
  Cyclid.logger.debug "api=#{Cyclid.config.server_api.inspect}"
@@ -48,17 +48,21 @@
48
48
  <li><a href="/{{.}}">{{.}}</a></li>
49
49
  {{/organizations}}
50
50
  {{#signup}}
51
+ {{#organization}}
51
52
  <li role="separator" class="divider"></li>
53
+ {{/organization}}
52
54
  <li><a href="{{signup}}/organization" target="_blank">Create a new Organization</a></li>
53
55
  {{/signup}}
54
56
  </ul>
55
57
  </li>
56
58
  </ul>
57
59
 
60
+ {{#organization}}
58
61
  <ul class="nav navbar-nav">
59
62
  <li><a href="/{{organization}}">Jobs</a></li>
60
63
  <li><a href="/{{organization}}/config">Configuration</a></li>
61
64
  </ul>
65
+ {{/organization}}
62
66
 
63
67
  <ul class="nav navbar-nav navbar-right">
64
68
  <li class="dropdown">
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Cyclid
3
3
  module UI
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
6
6
  end
@@ -173,13 +173,22 @@ function ji_update_all(job) {
173
173
  }
174
174
 
175
175
  function ji_get_failed(xhr) {
176
- var failure_message = `<p>
177
- <h2>Failed to retrieve job</h2><br>
178
- <strong>${xhr.status}:</strong> ${xhr.responseText}
179
- </p>`
180
- $('#ji_failure > #error_message').html(failure_message);
176
+ // 401 Unauthorized means an obvious authentication issue, and the user
177
+ // should log in again. A status of 0 here means that an error occured
178
+ // during the AJAX request; possible a CORS issue. In that case we'll assume
179
+ // the worst (cyclid.token is invalid) and force re-authentication, too.
180
+ if(xhr.status == 401 || xhr.status == 0){
181
+ console.log(`Failed to retrieve job list: status was ${xhr.status}`);
182
+ window.location = '/login';
183
+ } else {
184
+ var failure_message = `<p>
185
+ <h2>Failed to retrieve job</h2><br>
186
+ <strong>${xhr.status}:</strong> ${xhr.responseText}
187
+ </p>`
188
+ $('#ji_failure > #error_message').html(failure_message);
181
189
 
182
- $('#ji_failure').removeClass('hidden');
190
+ $('#ji_failure').removeClass('hidden');
191
+ }
183
192
  }
184
193
 
185
194
  function ji_update_status_and_check_completion(url, job) {
@@ -70,13 +70,22 @@ function org_add_job(job, append) {
70
70
  }
71
71
 
72
72
  function org_job_list_failed(xhr) {
73
- var failure_message = `Failed to retrieve job list<br>
74
- <strong>${xhr.status}:</strong> ${xhr.responseText}`;
73
+ // 401 Unauthorized means an obvious authentication issue, and the user
74
+ // should log in again. A status of 0 here means that an error occured
75
+ // during the AJAX request; possible a CORS issue. In that case we'll assume
76
+ // the worst (cyclid.token is invalid) and force re-authentication, too.
77
+ if(xhr.status == 401 || xhr.status == 0){
78
+ console.log(`Failed to retrieve job list: status was ${xhr.status}`);
79
+ window.location = '/login';
80
+ } else {
81
+ var failure_message = `Failed to retrieve job list<br>
82
+ <strong>${xhr.status}:</strong> ${xhr.responseText}`;
75
83
 
76
- failure_message = `List failed: ${xhr.status}`;
77
- $('#organization_failure > #error_message').html(failure_message);
84
+ failure_message = `List failed: ${xhr.status}`;
85
+ $('#organization_failure > #error_message').html(failure_message);
78
86
 
79
- $('#organization_failure').removeClass('hidden');
87
+ $('#organization_failure').removeClass('hidden');
88
+ }
80
89
  }
81
90
 
82
91
  function org_update_job_list(jobs, append) {
@@ -4,11 +4,20 @@ function user_show_error(msg){
4
4
  }
5
5
 
6
6
  function user_get_failed(xhr){
7
- var failure_message = `Failed to retrieve user details<br>
8
- <strong>${xhr.status}:</strong> ${xhr.responseText}`;
9
- failure_message = `Get failed: ${xhr.status}`;
7
+ // 401 Unauthorized means an obvious authentication issue, and the user
8
+ // should log in again. A status of 0 here means that an error occured
9
+ // during the AJAX request; possible a CORS issue. In that case we'll assume
10
+ // the worst (cyclid.token is invalid) and force re-authentication, too.
11
+ if(xhr.status == 401 || xhr.status == 0){
12
+ console.log(`Failed to retrieve job list: status was ${xhr.status}`);
13
+ window.location = '/login';
14
+ } else {
15
+ var failure_message = `Failed to retrieve user details<br>
16
+ <strong>${xhr.status}:</strong> ${xhr.responseText}`;
17
+ failure_message = `Get failed: ${xhr.status}`;
10
18
 
11
- user_show_error(failure_message);
19
+ user_show_error(failure_message);
20
+ }
12
21
  }
13
22
 
14
23
  function user_update_details(user){
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclid-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Van Der Vliet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all