Open tmk3s opened 7 months ago
gem 'devise_token_auth' # トークン認証
railsのversion => Rails 7.1.1
docker-compose exec app bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find compatible versions
Because devise_token_auth >= 0.1.21.alpha2, < 0.1.23.alpha1 depends on rails ~> 4.1.4
and devise_token_auth < 0.1.21.alpha2 depends on rails ~> 4.1,
devise_token_auth < 0.1.23.alpha1 requires rails >= 4.1, < 5.A.
And because devise_token_auth >= 0.1.23.alpha1, < 0.1.31.beta3 depends on rails ~> 4.1
and devise_token_auth >= 0.1.31.beta3, < 0.1.37 depends on rails ~> 4.2,
devise_token_auth < 0.1.37 requires rails >= 4.1, < 5.A.
And because devise_token_auth >= 0.1.37, < 1.0.0.rc2 depends on rails < 6
and devise_token_auth >= 1.0.0.rc2, < 1.1.1 depends on rails >= 4.2.0, < 6,
devise_token_auth < 1.1.1 requires rails < 6.
And because devise_token_auth >= 1.1.1, < 1.1.5 depends on rails >= 4.2.0, < 6.1
and devise_token_auth >= 1.1.5, < 1.2.1 depends on rails >= 4.2.0, < 6.2,
devise_token_auth < 1.2.1 requires rails < 6.2.
So, because devise_token_auth >= 1.2.1 depends on rails >= 4.2.0, < 7.1
and Gemfile depends on rails ~> 7.1.1,
version solving has failed.
https://github.com/lynndylanhurley/devise_token_auth/issues/1608#issuecomment-1767766452
まだ未対応みたい
https://github.com/lynndylanhurley/devise_token_auth/issues/1608#issuecomment-1783928862
forkされたものを使ってみる gem 'devise_token_auth', :git => 'https://github.com/single-stop-tony/devise_token_auth' ↓ 成功
手順通りにやる https://devise-token-auth.gitbook.io/devise-token-auth/config
rails g devise_token_auth:install User auth
エラー
rails c
/usr/local/bundle/gems/activerecord-7.1.1/lib/active_record/dynamic_matchers.rb:22:in method_missing': undefined method
devise' for User:Class (NoMethodError)
参考:https://github.com/lynndylanhurley/devise_token_auth/issues/1579
rails generate devise:install
USER コメントアウトして、
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
# devise :database_authenticatable, :registerable,
# :recoverable, :rememberable, :validatable
# include DeviseTokenAuth::Concerns::User
end
/usr/local/bundle/gems/devise-4.9.3/lib/devise/rails/routes.rb:510:in `raise_no_devise_method_error!': User does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)
↓
User model削除
mount_devise_token_auth_for 'User', at: 'auth'
上記をコメントアウト
その上でrails generate devise:install
で成功
データ作成
POST http://localhost:8080/auth
{
"email": "aaaaaaa@example.com",
"password":"zaq12wsx"
}
const token = {}; token['access-token'] = localStorage.getItem('accessToken');
型 '"access-token"' の式を使用して型 '{}' にインデックスを付けることはできないため、要素は暗黙的に 'any' 型になります。
プロパティ 'access-token' は型 '{}' に存在しません。ts(7053)
↓
const token:{[key: string]: string | null;} = {}; token['access-token'] = localStorage.getItem('accessToken');
ActionDispatch::Request::Session::DisabledSessionError (Your application has sessions disabled. To write to the session you must first configure a session store):
↓
https://qiita.com/KazuyaInoue/items/2d4065ddf2237c66dfd4 https://blog.dnpp.org/api_only_rails7_with_devise
<Text {...register("name")} name='社名' defaultValue={company?.name}/>
// export default function Text({name, defaultValue}: { name: string, defaultValue: string }) {
// return (
// <div className='p-5'>
// <p className='text-gray-500 text-s'>{name}</p>
// <input className='w-full h-10 outline outline-1 outline-gray-300' defaultValue={defaultValue}/>
// </div>
// )
// }
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
https://qiita.com/s_taro/items/06ace4d323176a1f2fff https://ja.react.dev/reference/react/forwardRef#usage
field :gender, [Types::GenderType], null: true, description: '性別' => NG field :gender, Types::GenderType, null: true, description: '性別' => OK
module Types class EmployeeType < Types::BaseObject description "従業員" field :id, ID, null: false field :company_id, ID, null: false, description: '会社ID' field :code, String, null: false, description: '従業員番号' field :last_name, String, null: false, description: '姓'
last_nameはあるが。。NG
↓
モジュール 'front/components/setting/Layout.tsx' またはそれに対応する型宣言が見つかりません。ts(2307) => tsconfigは下記のように全部指定になっているので、
import Layout from '@/components/setting/Layout'; こんな感じでかけばOK