ishapi 0.1.8.181 → 0.1.8.184
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.
- checksums.yaml +4 -4
- data/app/controllers/ishapi/application_controller.rb +22 -0
- data/app/controllers/ishapi/galleries_controller.rb +1 -1
- data/app/controllers/ishapi/maps_controller.rb +3 -2
- data/app/controllers/ishapi/users/registrations_controller.rb +37 -0
- data/app/controllers/ishapi/users/sessions_controller.rb +35 -0
- data/app/controllers/ishapi/users_controller.rb +11 -23
- data/app/mailers/ishapi/application_mailer.rb +5 -5
- data/app/mailers/ishapi/confirmations_mailer.rb +14 -0
- data/app/views/ishapi/mailer/confirmation_instructions.html.erb +6 -0
- data/app/views/ishapi/mailer/email_changed.html.erb +7 -0
- data/app/views/ishapi/mailer/password_change.html.erb +3 -0
- data/app/views/ishapi/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/ishapi/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/ishapi/newsitems/_index.jbuilder +8 -2
- data/app/views/ishapi/users/login.jbuilder +1 -1
- data/config/routes.rb +8 -2
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e93690ab066b469e9fbe3d4449f9b7c043a1863131d8e88218dac7ab47932bb
|
4
|
+
data.tar.gz: c9dad9be7543cc96a93a3deac3c60dabd5af68112d831a70f084af5b86beedd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52be7d6e6eac7cf8b0b7b24e6c2a78aa4a764d70a814dcd4194ddf92afdde8229446d55ccf59f1bdc9308bf4f5950efc1953c73641f7953bb416f9bba7a73c0
|
7
|
+
data.tar.gz: 503ef711cbb47aac94e49eddfb0a7bf6ce8998628ab3a58ba8d743581115055bcef1560f10f087f97faf16343aa4d804b92e27a9ae35f04a074e576e8f974f66
|
@@ -32,6 +32,28 @@ class Ishapi::ApplicationController < ActionController::Base
|
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
35
|
+
## @TODO: implement completely! _vp_ 2022-08-24
|
36
|
+
def vote
|
37
|
+
|
38
|
+
votee = params[:votee_class_name].constantize.find(params[:votee_id])
|
39
|
+
|
40
|
+
authorize! :open_permission, Ishapi # @TODO: make this more rigid
|
41
|
+
|
42
|
+
out = votee.vote(voter_id: params[:voter_id], value: params[:value].to_sym)
|
43
|
+
|
44
|
+
if out
|
45
|
+
render json: {
|
46
|
+
status: 'ok',
|
47
|
+
}
|
48
|
+
else
|
49
|
+
render json: {
|
50
|
+
status: 'not_ok',
|
51
|
+
message: votee.errors.full_messages.join(', '),
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
35
57
|
private
|
36
58
|
|
37
59
|
## This returns an empty user if not logged in!
|
@@ -24,7 +24,7 @@ module Ishapi
|
|
24
24
|
@gallery = ::Gallery.unscoped.find_by :slug => params[:slug]
|
25
25
|
authorize! :show, @gallery
|
26
26
|
if @gallery.premium?
|
27
|
-
if current_user&.profile&.has_premium_purchase( @gallery )
|
27
|
+
if @current_user&.profile&.has_premium_purchase( @gallery )
|
28
28
|
render 'show_premium_unlocked'
|
29
29
|
else
|
30
30
|
render 'show_premium_locked'
|
@@ -5,13 +5,14 @@ class Ishapi::MapsController < Ishapi::ApplicationController
|
|
5
5
|
before_action :check_profile, only: [ :show ]
|
6
6
|
|
7
7
|
def show
|
8
|
-
@location
|
8
|
+
@location = ::Gameui::Map.where( slug: params[:slug] ).first
|
9
|
+
@location ||= ::Gameui::Map.find params[:slug]
|
9
10
|
@map = @location.map || @location
|
10
11
|
|
11
12
|
authorize! :show, @map
|
12
13
|
@newsitems = @location.newsitems
|
13
14
|
|
14
|
-
@markers = @map.markers.permitted_to(current_user.profile)
|
15
|
+
@markers = @map.markers.permitted_to(@current_user.profile)
|
15
16
|
|
16
17
|
@tags = @map.tags
|
17
18
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
class Ishapi::Users::RegistrationsController < Devise::RegistrationsController
|
3
|
+
skip_before_action :verify_authenticity_token
|
4
|
+
|
5
|
+
def create
|
6
|
+
build_resource(sign_up_params)
|
7
|
+
resource.save
|
8
|
+
resource.profile = Ish::UserProfile.create({ user: resource, email: resource.email })
|
9
|
+
yield resource if block_given?
|
10
|
+
if resource.persisted?
|
11
|
+
render json: {
|
12
|
+
status: :ok,
|
13
|
+
message: "You have successfully registered! Please verify your email by clicking on a link we just sent you, before logging in.",
|
14
|
+
}, status: 200
|
15
|
+
|
16
|
+
# if resource.active_for_authentication?
|
17
|
+
# set_flash_message! :notice, :signed_up
|
18
|
+
# sign_up(resource_name, resource)
|
19
|
+
# respond_with resource, location: after_sign_up_path_for(resource)
|
20
|
+
# else
|
21
|
+
# set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
|
22
|
+
# expire_data_after_sign_in!
|
23
|
+
# respond_with resource, location: after_inactive_sign_up_path_for(resource)
|
24
|
+
# end
|
25
|
+
else
|
26
|
+
render json: {
|
27
|
+
status: :not_ok,
|
28
|
+
message: "Cannot register: #{resource.errors.full_messages.join(', ')}",
|
29
|
+
}, status: 400
|
30
|
+
|
31
|
+
# clean_up_passwords resource
|
32
|
+
# set_minimum_password_length
|
33
|
+
# respond_with resource
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
class Ishapi::Users::SessionsController < Devise::SessionsController
|
3
|
+
skip_before_action :verify_authenticity_token
|
4
|
+
|
5
|
+
def create
|
6
|
+
self.resource = warden.authenticate!(auth_options)
|
7
|
+
set_flash_message!(:notice, :signed_in)
|
8
|
+
sign_in(resource_name, resource)
|
9
|
+
yield resource if block_given?
|
10
|
+
# respond_with resource, location: after_sign_in_path_for(resource)
|
11
|
+
|
12
|
+
## Send the jwt to client
|
13
|
+
@jwt_token = encode(user_id: @current_user.id.to_s)
|
14
|
+
@profile = @current_user.profile
|
15
|
+
render 'ishapi/users/login', format: :json, layout: false
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
## copy-pasted from application_controller
|
21
|
+
## jwt
|
22
|
+
def decode(token)
|
23
|
+
decoded = JWT.decode(token, Rails.application.secrets.secret_key_base.to_s)[0]
|
24
|
+
HashWithIndifferentAccess.new decoded
|
25
|
+
end
|
26
|
+
|
27
|
+
## copy-pasted from application_controller
|
28
|
+
## jwt
|
29
|
+
def encode(payload, exp = 48.hours.from_now) # @TODO: definitely change, right now I expire once in 2 days.
|
30
|
+
payload[:exp] = exp.to_i
|
31
|
+
JWT.encode(payload, Rails.application.secrets.secret_key_base.to_s)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
@@ -1,14 +1,15 @@
|
|
1
|
-
require_dependency "ishapi/application_controller"
|
1
|
+
# require_dependency "ishapi/application_controller"
|
2
2
|
|
3
3
|
module Ishapi
|
4
|
-
class UsersController < ApplicationController
|
4
|
+
class UsersController < Ishapi::ApplicationController
|
5
5
|
|
6
6
|
skip_authorization_check only: %i| create fb_sign_in login |
|
7
7
|
|
8
|
+
|
8
9
|
before_action :check_profile_hard, only: %i| account |
|
9
10
|
|
10
11
|
def account
|
11
|
-
@profile = current_user&.profile
|
12
|
+
@profile = @current_user&.profile
|
12
13
|
authorize! :show, @profile
|
13
14
|
render 'ishapi/users/account'
|
14
15
|
rescue CanCan::AccessDenied
|
@@ -18,16 +19,19 @@ module Ishapi
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def create
|
21
|
-
|
22
|
-
|
22
|
+
authorize! :open_permission, Ishapi
|
23
|
+
new_user_params = params[:user].permit!
|
24
|
+
|
25
|
+
@profile = Profile.new( email: new_user_params[:email] )
|
26
|
+
@user = User.new( email: new_user_params[:email], password: new_user_params[:password], profile: @profile )
|
23
27
|
|
24
28
|
if @profile.save && @user.save
|
25
29
|
@jwt_token = encode(user_id: @user.id.to_s)
|
26
30
|
render 'login'
|
27
31
|
else
|
28
32
|
render json: {
|
29
|
-
messages:
|
30
|
-
}, status:
|
33
|
+
messages: @user.errors.messages.merge( @profile.errors.messages ),
|
34
|
+
}, status: 400
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -37,21 +41,5 @@ module Ishapi
|
|
37
41
|
render :action => 'show'
|
38
42
|
end
|
39
43
|
|
40
|
-
def login
|
41
|
-
@current_user = User.where( email: params[:email] ).first
|
42
|
-
|
43
|
-
if !@current_user
|
44
|
-
render json: { status: :not_ok }, status: 401
|
45
|
-
return
|
46
|
-
end
|
47
|
-
if @current_user.valid_password?(params[:password])
|
48
|
-
# from: application_controller#long_term_token
|
49
|
-
|
50
|
-
# send the jwt to client
|
51
|
-
@jwt_token = encode(user_id: @current_user.id.to_s)
|
52
|
-
@profile = @current_user.profile
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
44
|
end
|
57
45
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
class Ishapi::ConfirmationsMailer < Devise::Mailer
|
3
|
+
# default from: '314658@gmail.com'
|
4
|
+
helper :application # gives access to all helpers defined within `application_helper`.
|
5
|
+
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
|
6
|
+
|
7
|
+
default template_path: 'ishapi/mailer' # to make sure that your mailer uses the devise views
|
8
|
+
|
9
|
+
def confirmation_instructions(record, token, opts={})
|
10
|
+
# headers["Custom-header"] = "Bar"
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>Hello <%= @email %>!</p>
|
2
|
+
|
3
|
+
<% if @resource.try(:unconfirmed_email?) %>
|
4
|
+
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
|
5
|
+
<% else %>
|
6
|
+
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
|
7
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
4
|
+
|
5
|
+
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
6
|
+
|
7
|
+
<p>If you didn't request this, please ignore this email.</p>
|
8
|
+
<p>Your password won't change until you access the link above and create a new one.</p>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
4
|
+
|
5
|
+
<p>Click the link below to unlock your account:</p>
|
6
|
+
|
7
|
+
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
|
@@ -12,6 +12,12 @@ json.newsitems do
|
|
12
12
|
|
13
13
|
json.description item.description
|
14
14
|
|
15
|
+
json.votes_score item.votes_score
|
16
|
+
if @current_user&.profile
|
17
|
+
json.current_user_vote_value item.vote_value(@current_user.profile.id)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
15
21
|
if item.gallery
|
16
22
|
json.id item.gallery_id.to_s
|
17
23
|
json.item_type item.gallery.class.name
|
@@ -62,9 +68,9 @@ json.newsitems do
|
|
62
68
|
|
63
69
|
if item.video
|
64
70
|
json.id item.video_id.to_s
|
65
|
-
|
71
|
+
## @TODO: why is this relation here? It's non-performant.
|
66
72
|
video = Video.unscoped.find( item.video_id )
|
67
|
-
json.item_type
|
73
|
+
json.item_type "Video"
|
68
74
|
json.partial! 'ishapi/videos/show', :video => video
|
69
75
|
end
|
70
76
|
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
|
1
2
|
Ishapi::Engine.routes.draw do
|
3
|
+
|
2
4
|
root :to => 'application#home'
|
3
5
|
post 'home', :to => 'application#home'
|
4
6
|
|
@@ -65,8 +67,12 @@ Ishapi::Engine.routes.draw do
|
|
65
67
|
post 'users/profile/update', to: 'user_profiles#update'
|
66
68
|
get 'users/profile', to: 'users#show' # @TODO: only for testing! accessToken must be hidden
|
67
69
|
match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
|
68
|
-
|
69
|
-
|
70
|
+
devise_scope :user do
|
71
|
+
post 'users/register', to: 'users/registrations#create'
|
72
|
+
post 'users/login', to: 'users/sessions#create'
|
73
|
+
end
|
74
|
+
|
75
|
+
post 'v1/vote/:votee_class_name/:votee_id/:voter_id/:value', to: 'application#vote'
|
70
76
|
|
71
77
|
get 'venues', :to => 'venues#index'
|
72
78
|
get 'venues/view/:venuename', :to => 'venues#show'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ishapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.184
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: devise
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
237
251
|
description: " Description of Ishapi."
|
238
252
|
email:
|
239
253
|
- piousbox@gmail.com
|
@@ -273,12 +287,15 @@ files:
|
|
273
287
|
- app/controllers/ishapi/stock_watches_controller.rb
|
274
288
|
- app/controllers/ishapi/tags_controller.rb
|
275
289
|
- app/controllers/ishapi/user_profiles_controller.rb
|
290
|
+
- app/controllers/ishapi/users/registrations_controller.rb
|
291
|
+
- app/controllers/ishapi/users/sessions_controller.rb
|
276
292
|
- app/controllers/ishapi/users_controller.rb
|
277
293
|
- app/controllers/ishapi/venues_controller.rb
|
278
294
|
- app/controllers/ishapi/videos_controller.rb
|
279
295
|
- app/helpers/ishapi/application_helper.rb
|
280
296
|
- app/jobs/ishapi/application_job.rb
|
281
297
|
- app/mailers/ishapi/application_mailer.rb
|
298
|
+
- app/mailers/ishapi/confirmations_mailer.rb
|
282
299
|
- app/models/ishapi/ability.rb
|
283
300
|
- app/views/ishapi/addresses/_show.jbuilder
|
284
301
|
- app/views/ishapi/application/_meta.jbuilder
|
@@ -300,6 +317,11 @@ files:
|
|
300
317
|
- app/views/ishapi/galleries/show.jbuilder
|
301
318
|
- app/views/ishapi/galleries/show_premium_locked.jbuilder
|
302
319
|
- app/views/ishapi/galleries/show_premium_unlocked.jbuilder
|
320
|
+
- app/views/ishapi/mailer/confirmation_instructions.html.erb
|
321
|
+
- app/views/ishapi/mailer/email_changed.html.erb
|
322
|
+
- app/views/ishapi/mailer/password_change.html.erb
|
323
|
+
- app/views/ishapi/mailer/reset_password_instructions.html.erb
|
324
|
+
- app/views/ishapi/mailer/unlock_instructions.html.erb
|
303
325
|
- app/views/ishapi/maps/_show.jbuilder
|
304
326
|
- app/views/ishapi/maps/index.jbuilder
|
305
327
|
- app/views/ishapi/maps/show.jbuilder
|