onlinegames_info_connect 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/images/onlinegames_info_connect/ogi_small_logo.png +0 -0
- data/app/assets/javascripts/onlinegames_info_connect/utils.js.coffee +35 -0
- data/app/controllers/application_controller.rb +2 -0
- data/app/controllers/control_center/languages_controller.rb +90 -0
- data/app/controllers/control_center/user_roles_controller.rb +88 -0
- data/app/controllers/control_center/users_controller.rb +103 -0
- data/app/controllers/session_controller.rb +113 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/session_helper.rb +2 -0
- data/app/models/base_user.rb +54 -0
- data/app/models/language.rb +3 -0
- data/app/models/user_event.rb +16 -0
- data/app/models/user_role.rb +4 -0
- data/app/views/control_center/dashboard.html.erb +5 -0
- data/app/views/control_center/languages/_form.html.erb +25 -0
- data/app/views/control_center/languages/edit.html.erb +6 -0
- data/app/views/control_center/languages/index.html.erb +22 -0
- data/app/views/control_center/languages/new.html.erb +5 -0
- data/app/views/control_center/languages/show.html.erb +13 -0
- data/app/views/control_center/user_roles/_form.html.erb +25 -0
- data/app/views/control_center/user_roles/edit.html.erb +6 -0
- data/app/views/control_center/user_roles/index.html.erb +25 -0
- data/app/views/control_center/user_roles/new.html.erb +5 -0
- data/app/views/control_center/user_roles/show.html.erb +15 -0
- data/app/views/control_center/users/_form.html.erb +14 -0
- data/app/views/control_center/users/edit.html.erb +6 -0
- data/app/views/control_center/users/index.html.erb +56 -0
- data/app/views/control_center/users/show.html.erb +95 -0
- data/app/views/layouts/admin.html.erb +45 -0
- data/app/views/layouts/none.html.erb +1 -0
- data/app/views/layouts/simple.html.erb +5 -0
- data/app/views/session/_signup.html.erb +31 -0
- data/app/views/session/index.html.erb +4 -0
- data/config/routes.rb +23 -0
- data/db/migrate/20100604210033_create_users.rb +87 -0
- data/db/migrate/20100604222947_create_languages.rb +13 -0
- data/db/migrate/20100607191655_create_guilds.rb +26 -0
- data/db/migrate/20100612173309_create_user_roles.rb +14 -0
- data/lib/onlinegames_info_connect.rb +4 -0
- data/lib/onlinegames_info_connect/authenticated_system.rb +91 -0
- data/lib/onlinegames_info_connect/engine.rb +14 -0
- data/lib/onlinegames_info_connect/oauth_friends.rb +24 -0
- data/lib/onlinegames_info_connect/oauth_guild.rb +19 -0
- data/lib/onlinegames_info_connect/oauth_medals.rb +11 -0
- data/lib/onlinegames_info_connect/oauth_messages.rb +21 -0
- data/lib/onlinegames_info_connect/oauth_premium.rb +43 -0
- data/lib/onlinegames_info_connect/oauth_users.rb +11 -0
- data/lib/onlinegames_info_connect/ogi_oauth.rb +35 -0
- data/lib/onlinegames_info_connect/ogi_token_api.rb +49 -0
- data/lib/onlinegames_info_connect/test_helper.rb +7 -0
- data/lib/onlinegames_info_connect/version.rb +3 -0
- data/lib/tasks/onlinegames_info_connect_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +49 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +5 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/oauth_mock.rb +167 -0
- data/test/onlinegames_info_connect_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +214 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8f9852f1f23241458c68af73c6b32a39d7e52b6
|
4
|
+
data.tar.gz: d04c56a27499ba1f6271de95aaa6d7e911476bd6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6fe18da53ae65dadcf8cb84888e2454ebbd103a7d552f6cb4f64500c38c0feefa2622575219256417caae03cf7cc06594caf0cefb4b532881427648edfe80cb
|
7
|
+
data.tar.gz: a71b870c6ba0687a12b450e180af6c56721075f04150e5f10aca8e82ae048091da8c88b9f832fdd3d9f376f8e53ec0ef4cf69958e5dae8ca37571cce0496dd67
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'OnlinegamesInfoConnect'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
Binary file
|
@@ -0,0 +1,35 @@
|
|
1
|
+
root = exports ? this
|
2
|
+
|
3
|
+
class root.Utils
|
4
|
+
formatRestTime: (milliseconds) ->
|
5
|
+
seconds = milliseconds / 1000
|
6
|
+
|
7
|
+
# Calc minutes
|
8
|
+
minutes = Math.floor(seconds / 60)
|
9
|
+
seconds -= minutes * 60
|
10
|
+
seconds = Math.floor(seconds)
|
11
|
+
|
12
|
+
# Calc hours
|
13
|
+
hours = Math.floor(minutes / 60)
|
14
|
+
minutes -= hours * 60
|
15
|
+
|
16
|
+
# Add zeros to seconds if needed
|
17
|
+
seconds = "0#{seconds}" if seconds < 10
|
18
|
+
minutes = "0#{minutes}" if minutes < 10
|
19
|
+
|
20
|
+
"#{hours}:#{minutes}:#{seconds}" if hours > 0
|
21
|
+
"#{minutes}:#{seconds}"
|
22
|
+
|
23
|
+
formatNumber: (number) ->
|
24
|
+
number += ''
|
25
|
+
x = number.split('.')
|
26
|
+
x1 = x[0]
|
27
|
+
x2 = if x.length > 1 then ',' + x[1] else ''
|
28
|
+
rgx = /(\d+)(\d{3})/
|
29
|
+
|
30
|
+
while rgx.test(x1)
|
31
|
+
x1 = x1.replace(rgx, '$1' + "." + "$2")
|
32
|
+
|
33
|
+
x1 + x2
|
34
|
+
|
35
|
+
root.utils = new Utils()
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module ControlCenter
|
2
|
+
class LanguagesController < ApplicationController
|
3
|
+
layout 'admin'
|
4
|
+
require_role 'languages'
|
5
|
+
|
6
|
+
# GET /languages
|
7
|
+
# GET /languages.xml
|
8
|
+
def index
|
9
|
+
@languages = Language.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html # index.html.erb
|
13
|
+
format.xml { render :xml => @languages }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /languages/1
|
18
|
+
# GET /languages/1.xml
|
19
|
+
def show
|
20
|
+
@language = Language.find(params[:id])
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html # show.html.erb
|
24
|
+
format.xml { render :xml => @language }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /languages/new
|
29
|
+
# GET /languages/new.xml
|
30
|
+
def new
|
31
|
+
@language = Language.new
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.html # new.html.erb
|
35
|
+
format.xml { render :xml => @language }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# GET /languages/1/edit
|
40
|
+
def edit
|
41
|
+
@language = Language.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
# POST /languages
|
45
|
+
# POST /languages.xml
|
46
|
+
def create
|
47
|
+
@language = Language.new(params[:language])
|
48
|
+
|
49
|
+
respond_to do |format|
|
50
|
+
if @language.save
|
51
|
+
flash[:notice] = 'Language was successfully created.'
|
52
|
+
format.html { redirect_to(@language) }
|
53
|
+
format.xml { render :xml => @language, :status => :created, :location => @language }
|
54
|
+
else
|
55
|
+
format.html { render :action => "new" }
|
56
|
+
format.xml { render :xml => @language.errors, :status => :unprocessable_entity }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# PUT /languages/1
|
62
|
+
# PUT /languages/1.xml
|
63
|
+
def update
|
64
|
+
@language = Language.find(params[:id])
|
65
|
+
|
66
|
+
respond_to do |format|
|
67
|
+
if @language.update_attributes(params[:language])
|
68
|
+
flash[:notice] = 'Language was successfully updated.'
|
69
|
+
format.html { redirect_to(@language) }
|
70
|
+
format.xml { head :ok }
|
71
|
+
else
|
72
|
+
format.html { render :action => "edit" }
|
73
|
+
format.xml { render :xml => @language.errors, :status => :unprocessable_entity }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# DELETE /languages/1
|
79
|
+
# DELETE /languages/1.xml
|
80
|
+
def destroy
|
81
|
+
@language = Language.find(params[:id])
|
82
|
+
@language.destroy
|
83
|
+
|
84
|
+
respond_to do |format|
|
85
|
+
format.html { redirect_to(languages_url) }
|
86
|
+
format.xml { head :ok }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module ControlCenter
|
2
|
+
class UserRolesController < ApplicationController
|
3
|
+
layout 'admin'
|
4
|
+
require_role 'user_roles'
|
5
|
+
|
6
|
+
# GET /user_roles
|
7
|
+
# GET /user_roles.xml
|
8
|
+
def index
|
9
|
+
@user_roles = UserRole.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html # index.html.erb
|
13
|
+
format.xml { render :xml => @user_roles }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /user_roles/1
|
18
|
+
# GET /user_roles/1.xml
|
19
|
+
def show
|
20
|
+
@user_role = UserRole.find(params[:id])
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html # show.html.erb
|
24
|
+
format.xml { render :xml => @user_role }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /user_roles/new
|
29
|
+
# GET /user_roles/new.xml
|
30
|
+
def new
|
31
|
+
@user_role = UserRole.new
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.html # new.html.erb
|
35
|
+
format.xml { render :xml => @user_role }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# GET /user_roles/1/edit
|
40
|
+
def edit
|
41
|
+
@user_role = UserRole.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
# POST /user_roles
|
45
|
+
# POST /user_roles.xml
|
46
|
+
def create
|
47
|
+
@user_role = UserRole.new(params[:user_role])
|
48
|
+
|
49
|
+
respond_to do |format|
|
50
|
+
if @user_role.save
|
51
|
+
format.html { redirect_to(admin_user_role_path(@user_role), :notice => 'User role was successfully created.') }
|
52
|
+
format.xml { render :xml => @user_role, :status => :created, :location => @user_role }
|
53
|
+
else
|
54
|
+
format.html { render :action => "new" }
|
55
|
+
format.xml { render :xml => @user_role.errors, :status => :unprocessable_entity }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# PUT /user_roles/1
|
61
|
+
# PUT /user_roles/1.xml
|
62
|
+
def update
|
63
|
+
@user_role = UserRole.find(params[:id])
|
64
|
+
|
65
|
+
respond_to do |format|
|
66
|
+
if @user_role.update_attributes(params[:user_role])
|
67
|
+
format.html { redirect_to(admin_user_role_path(@user_role), :notice => 'User role was successfully updated.') }
|
68
|
+
format.xml { head :ok }
|
69
|
+
else
|
70
|
+
format.html { render :action => "edit" }
|
71
|
+
format.xml { render :xml => @user_role.errors, :status => :unprocessable_entity }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# DELETE /user_roles/1
|
77
|
+
# DELETE /user_roles/1.xml
|
78
|
+
def destroy
|
79
|
+
@user_role = UserRole.find(params[:id])
|
80
|
+
@user_role.destroy
|
81
|
+
|
82
|
+
respond_to do |format|
|
83
|
+
format.html { redirect_to(admin_user_roles_url) }
|
84
|
+
format.xml { head :ok }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module ControlCenter
|
2
|
+
class UsersController < ApplicationController
|
3
|
+
layout 'admin'
|
4
|
+
require_role 'users'
|
5
|
+
|
6
|
+
# GET /users
|
7
|
+
# GET /users.xml
|
8
|
+
def index
|
9
|
+
@users = User.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html # index.html.erb
|
13
|
+
format.xml { render :xml => @users }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /users/1
|
18
|
+
# GET /users/1.xml
|
19
|
+
def show
|
20
|
+
@user = User.find(params[:id])
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html # show.html.erb
|
24
|
+
format.xml { render :xml => @user }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# GET /users/new
|
29
|
+
# GET /users/new.xml
|
30
|
+
def new
|
31
|
+
@user = User.new
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.html # new.html.erb
|
35
|
+
format.xml { render :xml => @user }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# GET /users/1/edit
|
40
|
+
def edit
|
41
|
+
@user = User.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def login
|
45
|
+
@user = User.find(params[:id])
|
46
|
+
return redirect_to control_center_path if @user.nil? or not has_permission('change_user')
|
47
|
+
|
48
|
+
session[:user_id] = @user.id
|
49
|
+
redirect_to game_path
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_user
|
53
|
+
@user = User.find(params[:id])
|
54
|
+
flash[:notice] = check_user_data(@user)
|
55
|
+
|
56
|
+
redirect_to :action => :index
|
57
|
+
end
|
58
|
+
|
59
|
+
# POST /users
|
60
|
+
# POST /users.xml
|
61
|
+
def create
|
62
|
+
@user = User.new(params[:user])
|
63
|
+
|
64
|
+
respond_to do |format|
|
65
|
+
if @user.save
|
66
|
+
format.html { redirect_to(@user, :notice => 'User was successfully created.') }
|
67
|
+
format.xml { render :xml => @user, :status => :created, :location => @user }
|
68
|
+
else
|
69
|
+
format.html { render :action => "new" }
|
70
|
+
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# PUT /users/1
|
76
|
+
# PUT /users/1.xml
|
77
|
+
def update
|
78
|
+
@user = User.find(params[:id])
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
if @user.update_attributes(params[:user])
|
82
|
+
format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
|
83
|
+
format.xml { head :ok }
|
84
|
+
else
|
85
|
+
format.html { render :action => "edit" }
|
86
|
+
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# DELETE /users/1
|
92
|
+
# DELETE /users/1.xml
|
93
|
+
def destroy
|
94
|
+
@user = User.find(params[:id])
|
95
|
+
@user.destroy
|
96
|
+
|
97
|
+
respond_to do |format|
|
98
|
+
format.html { redirect_to(users_url) }
|
99
|
+
format.xml { head :ok }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
class SessionController < ApplicationController
|
2
|
+
before_filter :require_no_user, :except => [:destroy]
|
3
|
+
|
4
|
+
def index
|
5
|
+
@user = User.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
redirect_to OnlinegamesInfoConnect::OgiOauth.instance.authorize(callback_url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def callback
|
13
|
+
@user_events = UserEvent.new
|
14
|
+
|
15
|
+
if params[:error]
|
16
|
+
error_msg = t("An error occurred")
|
17
|
+
error_msg = t("You need to allow this application the login") if params[:error] == 'access_denied'
|
18
|
+
|
19
|
+
flash[:error] = error_msg
|
20
|
+
return redirect_to login_path
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get token & data about player
|
24
|
+
token = OnlinegamesInfoConnect::OgiOauth.instance.get_token params[:code], callback_url
|
25
|
+
me = OnlinegamesInfoConnect::OgiOauth.instance.me(token)
|
26
|
+
|
27
|
+
# Load user
|
28
|
+
@user = User.where(ogi_uid: me['id']).first
|
29
|
+
|
30
|
+
if not @user.nil? and @user.user_status != 'active'
|
31
|
+
flash[:notice] = :account_not_active_ask_support.l
|
32
|
+
return redirect_to login_url
|
33
|
+
elsif @user.nil?
|
34
|
+
@user = User.new(:ogi_uid => me['id'], :name => nil, :email => me['email'], :current_login_ip => request.remote_ip, :char_id => me['char_id'])
|
35
|
+
|
36
|
+
# Set campaign and ref_id
|
37
|
+
@user.campaign = cookies[:campaign]
|
38
|
+
@user.ref_id = params[:ref_id] if not params[:ref_id].nil?
|
39
|
+
@user.ref_id = cookies[:ref_id] if not cookies[:ref_id].nil?
|
40
|
+
|
41
|
+
if @user.save!
|
42
|
+
initialize_new_user(@user)
|
43
|
+
flash[:notice] = t("Account created")
|
44
|
+
else
|
45
|
+
flash[:notice] = t("Account creation error")
|
46
|
+
return redirect_to login_url
|
47
|
+
end
|
48
|
+
else
|
49
|
+
if (@user.last_login_at.day + 1) == @user.current_login_at.day then
|
50
|
+
@user.daily_login_count += 1
|
51
|
+
|
52
|
+
# Experience Config
|
53
|
+
bonuses = GameBase::get_daily_login_bonus
|
54
|
+
|
55
|
+
# Select Bonus
|
56
|
+
bonus = bonuses[@user.daily_login_count].nil? ? bonuses.last : bonuses[@user.daily_login_count]
|
57
|
+
|
58
|
+
# Add Bonus
|
59
|
+
GameBase::set_bonus(@user, bonus)
|
60
|
+
|
61
|
+
@user_events.add_event({event_type: 'daily_login_bonus', days: @user.daily_login_count, dialog_id: "dialog-daily_login_bonus", bonus: bonus, bonuses: bonuses})
|
62
|
+
|
63
|
+
# Track daily login
|
64
|
+
Resque.enqueue(TrackActionWorker, @user.id, 'daily_login')
|
65
|
+
elsif @user.last_login_at.day != @user.current_login_at.day
|
66
|
+
@user.daily_login_count = 0
|
67
|
+
end
|
68
|
+
|
69
|
+
# Set flash message
|
70
|
+
flash[:notice] = t("Login successful!")
|
71
|
+
|
72
|
+
# Check Vacation
|
73
|
+
if not @user.vacation.nil?
|
74
|
+
@user.vacation = nil
|
75
|
+
flash[:notice] = t("Vacation mode deactivated!")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Set User Login
|
80
|
+
@user.user_login(request.remote_ip)
|
81
|
+
|
82
|
+
# Check User data
|
83
|
+
check_user_data(@user)
|
84
|
+
|
85
|
+
# User save
|
86
|
+
@user.coins = me['coins'].to_i
|
87
|
+
@user.oauth_token = token.token
|
88
|
+
@user.save!
|
89
|
+
|
90
|
+
# Save User ID
|
91
|
+
session[:logged_in_user_id] = @user.id
|
92
|
+
session[:user_id] = @user.id.to_s
|
93
|
+
session[:logged_in_at] = Time.now
|
94
|
+
session[:premium_time] = @user.premium_time
|
95
|
+
session[:possible_user_names] = me['possible_user_names'] if not me['possible_user_names'].nil?
|
96
|
+
|
97
|
+
return redirect_to game_url
|
98
|
+
end
|
99
|
+
|
100
|
+
def destroy
|
101
|
+
# Get redirect url
|
102
|
+
result = OnlinegamesInfoConnect::OgiTokenApi.instance.logout_page(current_user, request.remote_ip)
|
103
|
+
|
104
|
+
# Reset session
|
105
|
+
reset_session
|
106
|
+
flash[:notice] = t("Logout successful!")
|
107
|
+
|
108
|
+
return redirect_to result['url'] if not result.nil? and not result['status'].nil? and "ok".eql?(result['status'])
|
109
|
+
|
110
|
+
redirect_back_or_default login_url
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|