You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a rails API, and through adding twilio-ruby gem to verify phone number of Customer, I added a new action to RegistrationsController after overriding it and this controller look like:
class Api::V1::Customers::RegistrationsController < DeviseTokenAuth::RegistrationsController
def verify
@customer = Customer.find_by(mobile_phone_number: request.headers[:mobile_phone_number])
@customer.verify(request.headers[:pin_code])
if @customer.verified
render json: {message: 'You are verified'}
else
render json: {message: 'You have entered wrong pin code'}
end
end
end
and Customer model is
class Customer < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :omniauthable
include DeviseTokenAuth::Concerns::User
def verify(entered_pin)
update(verified: true) if self.pin_code == entered_pin
end
end
routes.rb file is
namespace 'api' do
namespace 'v1' do
mount_devise_token_auth_for 'Customer', at: 'customer/auth', controllers: {
registrations: 'api/v1/customers/registrations',
sessions: 'api/v1/customers/sessions'
}
end
end
then I add these lines underneath the above block in routes.rb to get the access to the new action verify:
devise_scope :customer do
get "api/v1/customer/auth/pincode" => "api/v1/customers/registrations#verify"
end
After I ran rails routes, I got api_v1_customer_auth_pincode GET /api/v1/customer/auth/pincode(.:format) api/v1/customers/registrations#verify
and after running rails routes I got this:
new_api_v1_customer_session GET /api/v1/customer/auth/sign_in(.:format) api/v1/customers/sessions#new
api_v1_customer_session POST /api/v1/customer/auth/sign_in(.:format) api/v1/customers/sessions#create
destroy_api_v1_customer_session DELETE /api/v1/customer/auth/sign_out(.:format) api/v1/customers/sessions#destroy
new_api_v1_customer_password GET /api/v1/customer/auth/password/new(.:format) devise_token_auth/passwords#new
edit_api_v1_customer_password GET /api/v1/customer/auth/password/edit(.:format) devise_token_auth/passwords#edit
api_v1_customer_password PATCH /api/v1/customer/auth/password(.:format) devise_token_auth/passwords#update
PUT /api/v1/customer/auth/password(.:format) devise_token_auth/passwords#update
POST /api/v1/customer/auth/password(.:format) devise_token_auth/passwords#create
cancel_api_v1_customer_registration GET /api/v1/customer/auth/cancel(.:format) api/v1/customers/registrations#cancel
new_api_v1_customer_registration GET /api/v1/customer/auth/sign_up(.:format) api/v1/customers/registrations#new
edit_api_v1_customer_registration GET /api/v1/customer/auth/edit(.:format) api/v1/customers/registrations#edit
api_v1_customer_registration PATCH /api/v1/customer/auth(.:format) api/v1/customers/registrations#update
PUT /api/v1/customer/auth(.:format) api/v1/customers/registrations#update
DELETE /api/v1/customer/auth(.:format) api/v1/customers/registrations#destroy
POST /api/v1/customer/auth(.:format) api/v1/customers/registrations#create
new_api_v1_customer_confirmation GET /api/v1/customer/auth/confirmation/new(.:format) devise_token_auth/confirmations#new
api_v1_customer_confirmation GET /api/v1/customer/auth/confirmation(.:format) devise_token_auth/confirmations#show
POST /api/v1/customer/auth/confirmation(.:format) devise_token_auth/confirmations#create
api_v1_customer_auth_validate_token GET /api/v1/customer/auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
api_v1_customer_auth_failure GET /api/v1/customer/auth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
GET /api/v1/customer/auth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#omniauth_success
GET|POST /omniauth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#redirect_callbacks
GET|POST /omniauth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
GET /api/v1/customer/auth/:provider(.:format) redirect(301)
api_v1_customer_auth_pincode GET /api/v1/customer/auth/pincode(.:format) api/v1/customers/registrations#verify
The problem is each time I try to access http://localhost:3000/api/v1/customer/auth/pincode
I got this error in rails stack trace is
Started GET "/api/v1/customer/auth/pincode" for 127.0.0.1 at 2018-01-04 15:53:59 +0300
(0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY
"schema_migrations"."version" ASC Started GET "/omniauth/pincode?
namespace_name=api_v1&resource_class=Customer" for 127.0.0.1 at 2018-01-04 15:53:59 +0300
ActionController::RoutingError (No route matches [GET] "/omniauth/pincode"):
I don't understand what's going on!
Why omniauth is got the error ?
So any explanation!
The text was updated successfully, but these errors were encountered:
Gemfile
I'm building a rails API, and through adding
twilio-ruby
gem to verify phone number ofCustomer
, I added a new action toRegistrationsController
after overriding it and this controller look like:and
Customer
model isroutes.rb
file isthen I add these lines underneath the above block in
routes.rb
to get the access to the new actionverify
:After I ran
rails routes
, I gotapi_v1_customer_auth_pincode GET /api/v1/customer/auth/pincode(.:format) api/v1/customers/registrations#verify
and after running
rails routes
I got this:The problem is each time I try to access
http://localhost:3000/api/v1/customer/auth/pincode
I got this error in rails stack trace is
I don't understand what's going on!
Why
omniauth
is got the error ?So any explanation!
The text was updated successfully, but these errors were encountered: