app/controllers/application_controller.rb
# check whether there is an authorization header in the request
# take the token from the request headers, if there is a token decode it, otherwise return nil
check whether there is an authorization header in the request
take the token from the request headers, if there is a token decode it, otherwise return nil
check whether there is an authorization header in the request take the token from the request headers if there is a token decode it otherwise return nil
def decoded_token
        if auth_header
            token = auth_header
            begin
                JWT.decode(token, secret, true, algorithm: 'HS256')
            rescue JWT::DecodeError
                nil
            end
        end
    end
def decoded_token if auth_header token = auth_header begin JWT . decode ( token , secret , true , algorithm : 'HS256' ) rescue JWT :: DecodeError nil end end end
check whether there is an authorization header in the request
take the token from the request headers, if there is a token decode it, otherwise return nil
check whether there is an authorization header in the request take the token from the request headers if there is a token decode it otherwise return nil
# puts token