ishapi 0.1.8.145 → 0.1.8.146

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
  SHA256:
3
- metadata.gz: 3f0fad3c980c7518b84af9b012e1f9e38bdb857acb62628d0d642436b9e6b8a7
4
- data.tar.gz: dc425ab3037bff825d77171afd9b4ad3e844d6df9783a5df303e36ac67677bd0
3
+ metadata.gz: 7daed337d478761f910b4330f860a5c730a858dc50cf75272ef05ff6609459ef
4
+ data.tar.gz: 63ca6a01982f267a5cc411b32a0a949abb3d97ff5a2cdd43454b2a301607d8cd
5
5
  SHA512:
6
- metadata.gz: c50270ea8baf769301620c64caab386ca556c35ae7f81221518104cb2a0ebd94d5be3aad0786724aae98b91dc902dc4a6b1bc383d1fe2c5d2ab7207eb076b6e5
7
- data.tar.gz: 174b6dcd1bcb7e0a6159b223aaf15d439af32f1484ed4b612c9cdb732863ee2f22fb6903341c4cb213b28372ed701a3db8f19ad406aa117fd843d1fed1d759a6
6
+ metadata.gz: 23e0af13c63e3ad5f24621cfd93f680f946bdebadc10d8bc2e5ed41a962c2c901237d839ae3f27a19ca01ede1e5cd73fe84649962247168db1127768c52dfb40
7
+ data.tar.gz: 1a0d67e6ff177b1d474538e4fb9a2770fb3f14872355a9ddba3b1cadeb69feaa644d3e3aa78b2d7e6fce1685e26bee74f9e6fd3f5c0551b576cdf9c71d2141b5
@@ -37,7 +37,7 @@ module Ishapi
37
37
  rescue JWT::ExpiredSignature, JWT::DecodeError => e
38
38
  puts! e, 'ee1'
39
39
  flash[:notice] = 'You arent logged in, or you have been logged out.'
40
- @current_user = User.new
40
+ # @current_user = User.new
41
41
  end
42
42
  end
43
43
 
@@ -8,8 +8,12 @@ module Ishapi
8
8
  before_action :check_profile
9
9
 
10
10
  def account
11
- @profile = current_user.profile
11
+ @profile = current_user&.profile
12
12
  authorize! :show, @profile
13
+ rescue CanCan::AccessDenied
14
+ render json: {
15
+ status: :not_ok,
16
+ }, status: 401
13
17
  end
14
18
 
15
19
  private
@@ -4,6 +4,8 @@ module Ishapi
4
4
  class UsersController < ApplicationController
5
5
  before_action :set_profile, :only => [ :fb_sign_in, :show ]
6
6
 
7
+ skip_authorization_check only: %i| login |
8
+
7
9
  def fb_sign_in
8
10
  authorize! :fb_sign_in, Ishapi
9
11
  # render :json => { :status => :ok }
@@ -14,5 +16,25 @@ module Ishapi
14
16
  authorize! :fb_sign_in, Ishapi
15
17
  end
16
18
 
19
+ def login
20
+ @current_user = User.where( email: params[:email] ).first
21
+ if !@current_user
22
+ render json: { status: :not_ok }, status: 401
23
+ return
24
+ end
25
+ if @current_user.valid_password?(params[:password])
26
+ # from: application_controller#long_term_token
27
+
28
+ # send the jwt to client
29
+ @jwt_token = encode(user_id: @current_user.id.to_s)
30
+ render json: {
31
+ email: @current_user.email,
32
+ jwt_token: @jwt_token,
33
+ long_term_token: @long_term_token,
34
+ n_unlocks: @current_user.profile.n_unlocks,
35
+ }
36
+ end
37
+ end
38
+
17
39
  end
18
40
  end
data/config/routes.rb CHANGED
@@ -66,6 +66,7 @@ Ishapi::Engine.routes.draw do
66
66
  post 'users/profile/update', :to => 'users#update'
67
67
  get 'users/profile', :to => 'users#show' # @TODO: only for testing! accessToken must be hidden
68
68
  match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
69
+ post 'users/login', to: 'users#login'
69
70
 
70
71
  get 'venues', :to => 'venues#index'
71
72
  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.145
4
+ version: 0.1.8.146
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails