ishapi 0.1.8.176 → 0.1.8.177

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 534814e2570fd0506905da3c2af5baa3b54b7e23762ae0b1d43c7b733747a46d
4
- data.tar.gz: 00f9f2f19642d1c51c3a1893d2657c1a77ee5e2254aa6ee4930b0bf33b307b86
3
+ metadata.gz: 3d2316758e2797aeecb65f3e8cacdb034902a7271f8518da15707050bf64e097
4
+ data.tar.gz: ba8bc72419963ea42441cee3dfd3b537aa79d3bf8dd21ff5fa4f44f7e77b37c7
5
5
  SHA512:
6
- metadata.gz: 53c030593cf235e01ca9b671b63bd47bfee8db9c2b9a84a8d10db01b401cadda3f6a14b7608f0a23ab888cb2fb8799a511798518060e76707e2accf1e9ca5d3a
7
- data.tar.gz: 2f44b2869368baa23d513ddc82b6749cc22b1e87b1b720d769a50e4976334261bd3a7682db0728a94f0194c4decab25a13419619a749015a727aff580e1eafca
6
+ metadata.gz: 33e25407dddeeafa0fe7e80e3483c0e674ebb36028644f69c4b37c2ac03787d93568cddad0ce6981d4c63c0f527c754a4bb572e6d4a8d622e215d212c9e9b22b
7
+ data.tar.gz: cfed72d717b27f1c7f303eace2491441f0e5108f2536a51fdedaf7c1ed00735012a16b2db13422e4dc6f93aff33a008e4a5b843685fd26fc4c443f3f22fcea60
@@ -2,12 +2,26 @@ require_dependency "ishapi/application_controller"
2
2
  module Ishapi
3
3
  class UserProfilesController < ApplicationController
4
4
 
5
- before_action :check_profile
5
+ before_action :check_profile, only: %i| show | ## @TODO: hmmm I may not need this check at all
6
+
7
+ before_action :check_profile_hard, only: %i| update |
6
8
 
7
9
  def show
8
- @profile = IshModels::UserProfile.find_by :username => params[:username]
10
+ @profile = Ish::UserProfile.find_by :username => params[:username]
9
11
  authorize! :show, @profile
10
12
  end
11
13
 
14
+ def update
15
+ @profile = Ish::UserProfile.find @current_user.profile
16
+ authorize! :update, @profile
17
+
18
+ flag = @profile.update params[:profile].permit!
19
+ if flag
20
+ render json: { message: 'ok' }, status: :ok
21
+ else
22
+ render json: { message: "No luck: #{@profile.errors.full_messages.join(", ")}." }, code: 400
23
+ end
24
+ end
25
+
12
26
  end
13
27
  end
@@ -33,6 +33,9 @@ class Ishapi::Ability
33
33
  user ||= User.new
34
34
 
35
35
  can [ :show ], Ish::UserProfile
36
+ can [ :update ], Ish::UserProfile do |p|
37
+ p.user.id.to_s == user.id.to_s
38
+ end
36
39
 
37
40
  can [ :index, :show ], City
38
41
 
data/config/routes.rb CHANGED
@@ -58,8 +58,8 @@ Ishapi::Engine.routes.draw do
58
58
 
59
59
  post 'users/fb_sign_in', to: 'users#fb_sign_in'
60
60
  get 'users/me', to: 'users#account'
61
- post 'users/profile', to: 'users#show'
62
- post 'users/profile/update', to: 'users#update'
61
+ post 'users/profile', to: 'users#show' ## @TODO: change, this makes no sense
62
+ post 'users/profile/update', to: 'user_profiles#update'
63
63
  get 'users/profile', to: 'users#show' # @TODO: only for testing! accessToken must be hidden
64
64
  match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
65
65
  post 'users/login', to: 'users#login'
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.176
4
+ version: 0.1.8.177
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-06 00:00:00.000000000 Z
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails