Work towards authentication through opening window
This commit is contained in:
@@ -15,7 +15,23 @@
|
||||
# frame = $('<iframe></iframe>').addClass('obtain-token-frame').attr 'src', $obtain_token_url
|
||||
# frame.css width: $('body').outerWidth(), height: $('body').outerHeight()
|
||||
# $('body').append frame
|
||||
window.location = "#{$obtain_token_url}"
|
||||
# window.location = "#{$obtain_token_url}"
|
||||
auth_win = window.open $obtain_token_url, "_blank", "location=no"
|
||||
auth_win.addEventListener "loadstop", ->
|
||||
# auth_win.executeScript(code: "localStorage.setItem( 'name', '' );")
|
||||
watch_loop = setInterval ->
|
||||
auth_win.executeScript {code: "localStorage.getItem( 'auth_token' )"}, (values)->
|
||||
token = values[0]
|
||||
if token
|
||||
clearInterval( watch_loop )
|
||||
auth_win.executeScript {code: "localStorage.setItem('auth_token', '');"}
|
||||
auth_win.executeScript {code: "localStorage.getItem( 'user_id' )"}, (user_id_values)->
|
||||
user_id = user_id_values[0]
|
||||
Qstorage.setItem 'user_id', user_id
|
||||
Qstorage.setItem 'auth_token', token
|
||||
auth_win.close()
|
||||
, 200
|
||||
|
||||
|
||||
Ember.$.ajaxPrefilter (options) ->
|
||||
if options.type.toUpperCase() == 'GET'
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
doctype html
|
||||
html lang="en"
|
||||
head
|
||||
meta charset="utf-8"
|
||||
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||
meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"
|
||||
title= application_title
|
||||
/ = stylesheet_link_tag 'obtain_token/application'
|
||||
/ = csrf_meta_tags
|
||||
|
||||
@@ -16,7 +16,7 @@ html lang="en"
|
||||
var $event_host = '#{Qwaiter.event_host}';
|
||||
var $asset_path = '##assets_path##';
|
||||
var Qstorage = window.localStorage;
|
||||
var Qstorage.setItem('root_url', '##root_url##');
|
||||
Qstorage.setItem('root_url', '##root_url##');
|
||||
var $platform = '##platform##';
|
||||
var $obtain_token_url = 'http://mozo.bar/user/obtain_token';
|
||||
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
.row
|
||||
h1 data-t='obtain_token.title' = t('user.obtain_token.title')
|
||||
hr
|
||||
/form
|
||||
.form-row
|
||||
.form-label
|
||||
label.control-label data-t='attributes.user.email' = User.human_attribute_name(:email)
|
||||
.form-field
|
||||
input#user-email.email type="email" placeholder=User.human_attribute_name(:email)
|
||||
.form-row
|
||||
.form-label
|
||||
label.control-label data-t='attributes.user.password' Password
|
||||
.form-field
|
||||
input#user-password.password type="password" placeholder="Password"
|
||||
.form-row
|
||||
.form-label
|
||||
.form-field
|
||||
button.btn.btn-primary data-t="obtain_token.obtain" onclick="Quser.authenticate_user(); return false" = t('user.obtain_token.obtain')
|
||||
- unless current_user.blank? || ENV['QWAITER_MOBILE_EXPORT']=='yes'
|
||||
- if current_user.present?
|
||||
p Waiting for authentication to complete.....
|
||||
javascript:
|
||||
Qstorage = window.localStorage;
|
||||
Qstorage.setItem('auth_token', '#{current_user.authentication_token}');
|
||||
Qstorage.setItem('user_id', '#{current_user.id}');
|
||||
window.location = (Qstorage.getItem('root_url') || '/user/index.html') + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}';
|
||||
if(window.opener && window.opener != window) window.close();
|
||||
// window.location = (Qstorage.getItem('root_url') || '/user/index.html') + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}';
|
||||
// localStorage.setItem('auth_token', '#{current_user.authentication_token}');
|
||||
// localStorage.setItem('user_id', '#{current_user.id}');
|
||||
// window.location = $root_url + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}';
|
||||
|
||||
+10
-6
@@ -13,10 +13,10 @@ include FileUtils
|
||||
Rails.application.routes.default_url_options = {format: 'html'} # append .html extension to asset paths
|
||||
|
||||
rails_assets_path = Rails.root.join('public', 'assets')
|
||||
android_root = '/Users/bterkuile/Documents/workspace/Qwaiter/assets'
|
||||
android_root = '/Users/bterkuile/Documents/workspace/mozo/www'
|
||||
ios_root = '/Users/bterkuile/Documents/iOS/Qwaiter/www'
|
||||
|
||||
android_root_url = "file:///Users/bterkuile/Documents/workspace/Qwaiter/assets"
|
||||
# android_root_url = "file:///Users/bterkuile/Documents/workspace/Qwaiter/assets"
|
||||
android_root_url = 'file:///android_asset'
|
||||
|
||||
# Cleanup and setup android structure
|
||||
@@ -46,12 +46,14 @@ move rails_assets_path, File.join(android_root, 'assets')
|
||||
|
||||
for css in Dir.glob(File.join(android_root, "**", "*.css"))
|
||||
contents = File.read(css)
|
||||
contents.gsub!(/url\("/, %|url("#{android_root_url}|)
|
||||
contents.gsub!(/url\(\//, %|url(#{android_root_url}/|)
|
||||
# contents.gsub!(/url\("/, %|url("#{android_root_url}|)
|
||||
# contents.gsub!(/url\(\//, %|url(#{android_root_url}/|)
|
||||
contents.gsub!(/url\("\/assets\//, %|url("../|)
|
||||
contents.gsub!(/url\(\/assets\//, %|url(../|)
|
||||
File.open(css, 'w'){|f| f.puts contents}
|
||||
end
|
||||
|
||||
|
||||
=begin
|
||||
uc = UserController.new
|
||||
class << uc
|
||||
def authenticate_user!
|
||||
@@ -86,7 +88,8 @@ for action in uc.action_methods
|
||||
#result.sub! /<head>/, '<head><base href="file:///Users/bterkuile/Documents/workspace/Qwaiter/assets/" target="_self" />'
|
||||
android_view = result.gsub /(href|src)="\/user\/([^"]+)/, %|\\1="/\\2| # replace absolute path names to relative ones
|
||||
android_view.gsub! /(href|src)="([^#])/, %|\\1="#{android_root_url}\\2| # replace relative uri's with android specific one
|
||||
android_view.sub! /<\/title>/, '</title><script type="text/javascript" src="qmobile.js"></script><script type="text/javascript" src="cordova-2.6.0rc1.js"></script><script type="text/javascript" src="barcodescanner.js"></script>'
|
||||
# android_view.sub! /<\/title>/, '</title><script type="text/javascript" src="qmobile.js"></script><script type="text/javascript" src="cordova-2.6.0rc1.js"></script><script type="text/javascript" src="barcodescanner.js"></script>'
|
||||
android_view.sub! /<\/title>/, '</title><script type="text/javascript" src="cordova.js"></script>'
|
||||
android_view.gsub! '##assets_path##', 'file:///android_asset/assets/'
|
||||
android_view.gsub! '##root_url##', 'file:///android_asset/user/index.html'
|
||||
android_view.gsub! '##platform##', 'android'
|
||||
@@ -111,4 +114,5 @@ class << view
|
||||
false
|
||||
end
|
||||
end
|
||||
=end
|
||||
# view.render()
|
||||
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
extensions = %w[jpg jpeg png js css gif svg json woff eot ttf otf ]
|
||||
Dir.glob(File.join('public/assets/**', "*.{#{extensions.join(',')}}")).each do |asset_path|
|
||||
next unless asset_path =~ /-[a-f0-9]{32}\.(#{extensions.join('|')})\Z/
|
||||
dedigest_path = asset_path.sub(/-[a-f0-9]{32}/, '')
|
||||
`mv '#{asset_path}' '#{dedigest_path}' 2>/dev/null`
|
||||
end
|
||||
@@ -28,7 +28,7 @@ Qwaiter::Application.configure do
|
||||
config.ember.variant = :production if defined?(Ember::Rails)
|
||||
|
||||
# Generate digests for assets URLs
|
||||
config.assets.digest = true
|
||||
config.assets.digest = false
|
||||
|
||||
# Defaults to nil and saved in location specified by config.assets.prefix
|
||||
# config.assets.manifest = YOUR_PATH
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
rm -rf public/assets;
|
||||
QWAITER_MOBILE_EXPORT=yes RAILS_ENV=production bundle exec rake assets:precompile;
|
||||
./bin/dedigest_assets
|
||||
rm -rf public/assets/cmtool;
|
||||
rm -rf public/assets/jquery-ui;
|
||||
rm -rf public/assets/admin;
|
||||
rm -rf public/assets/waiter;
|
||||
rm -rf public/assets/obtain_token;
|
||||
rm -rf public/assets/qr_sheet;
|
||||
rm -rf public/assets/supplier;
|
||||
rm -rf public/assets/site;
|
||||
rm -rf public/assets/cartoon;
|
||||
|
||||
Reference in New Issue
Block a user