Compare commits
2 Commits
API-can-fe
...
change-ame
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4af845217 | ||
|
|
50c5d678c5 |
@@ -1,12 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require './lib/knock_monkeypatch'
|
|
||||||
|
|
||||||
class Api::UserTokenController < Knock::AuthTokenController
|
class Api::UserTokenController < Knock::AuthTokenController
|
||||||
include Oath::ControllerHelpers
|
|
||||||
|
|
||||||
skip_before_action :verify_authenticity_token
|
skip_before_action :verify_authenticity_token
|
||||||
before_action :sign_in_user
|
|
||||||
|
|
||||||
rescue_from Exception, :with => :return_error
|
rescue_from Exception, :with => :return_error
|
||||||
|
|
||||||
@@ -42,10 +35,4 @@ class Api::UserTokenController < Knock::AuthTokenController
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def sign_in_user
|
|
||||||
sign_in(entity)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -511,6 +511,8 @@ en:
|
|||||||
person_last_name: Last name
|
person_last_name: Last name
|
||||||
person_name: Name
|
person_name: Name
|
||||||
person_phone: Phone number
|
person_phone: Phone number
|
||||||
|
contract_template:
|
||||||
|
amendment_clause: Additional Contract Clause
|
||||||
location_release:
|
location_release:
|
||||||
address_city: City
|
address_city: City
|
||||||
address_country: Country
|
address_country: Country
|
||||||
@@ -842,7 +844,7 @@ en:
|
|||||||
empty: Location Releases will appear here
|
empty: Location Releases will appear here
|
||||||
table_headers:
|
table_headers:
|
||||||
address: Address
|
address: Address
|
||||||
amendment_signed: Amendment
|
amendment_signed: Additional Clause
|
||||||
approved: Approved
|
approved: Approved
|
||||||
name: Location Name
|
name: Location Name
|
||||||
notes: Notes
|
notes: Notes
|
||||||
@@ -852,7 +854,7 @@ en:
|
|||||||
actions:
|
actions:
|
||||||
manage: Manage
|
manage: Manage
|
||||||
review: Review
|
review: Review
|
||||||
sign_amendment: Sign Amendment
|
sign_amendment: Sign Additional Clause
|
||||||
messages:
|
messages:
|
||||||
amendment_not_signed_tooltip: Amendment not yet signed
|
amendment_not_signed_tooltip: Amendment not yet signed
|
||||||
amendment_signed_tooltip: Amendment Signed
|
amendment_signed_tooltip: Amendment Signed
|
||||||
@@ -1134,7 +1136,7 @@ en:
|
|||||||
amendment_signed_message: Release amendment signed successfully! Thank you
|
amendment_signed_message: Release amendment signed successfully! Thank you
|
||||||
new:
|
new:
|
||||||
amendment:
|
amendment:
|
||||||
heading: Amendment
|
heading: Additional Clause
|
||||||
copy_url: Copy sign amendment URL
|
copy_url: Copy sign amendment URL
|
||||||
signature:
|
signature:
|
||||||
heading: Signature
|
heading: Signature
|
||||||
|
|||||||
@@ -285,6 +285,8 @@ es:
|
|||||||
person_email: Dirección de correo electrónico
|
person_email: Dirección de correo electrónico
|
||||||
person_name: Nómbre
|
person_name: Nómbre
|
||||||
person_phone: Número de teléfono
|
person_phone: Número de teléfono
|
||||||
|
contract_template:
|
||||||
|
amendment_clause: Additional Contract Clause (ES)
|
||||||
material_release:
|
material_release:
|
||||||
guardian_2_address_city: Guardian 2 city (ES)
|
guardian_2_address_city: Guardian 2 city (ES)
|
||||||
guardian_2_address_country: Guardian 2 country (ES)
|
guardian_2_address_country: Guardian 2 country (ES)
|
||||||
@@ -408,13 +410,13 @@ es:
|
|||||||
index:
|
index:
|
||||||
table_headers:
|
table_headers:
|
||||||
address: Address (ES)
|
address: Address (ES)
|
||||||
amendment_signed: Amendment (ES)
|
amendment_signed: Additional Clause (ES)
|
||||||
notes: Notes (ES)
|
notes: Notes (ES)
|
||||||
signed_at: Date Signed (ES)
|
signed_at: Date Signed (ES)
|
||||||
tags: Tags (ES)
|
tags: Tags (ES)
|
||||||
location_release:
|
location_release:
|
||||||
actions:
|
actions:
|
||||||
sign_amendment: Sign Amendment (ES)
|
sign_amendment: Sign Additional Clause (ES)
|
||||||
messages:
|
messages:
|
||||||
amendment_not_signed_tooltip: Amendment not yet signed (ES)
|
amendment_not_signed_tooltip: Amendment not yet signed (ES)
|
||||||
amendment_signed_tooltip: Amendment Signed (ES)
|
amendment_signed_tooltip: Amendment Signed (ES)
|
||||||
@@ -500,7 +502,7 @@ es:
|
|||||||
amendment_signed_message: Release amendment signed successfully! Thank you (ES)
|
amendment_signed_message: Release amendment signed successfully! Thank you (ES)
|
||||||
new:
|
new:
|
||||||
amendment:
|
amendment:
|
||||||
heading: Amendment
|
heading: Additional Clause (ES)
|
||||||
copy_url: Copy sign amendment URL (ES)
|
copy_url: Copy sign amendment URL (ES)
|
||||||
signature:
|
signature:
|
||||||
heading: Signature (ES)
|
heading: Signature (ES)
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
module Knock
|
|
||||||
class AuthTokenController < ApplicationController
|
|
||||||
skip_before_action :authenticate
|
|
||||||
alias authenticate_with_token authenticate
|
|
||||||
before_action :authenticate_with_token
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Api::UserTokenController, type: :request do
|
|
||||||
let(:current_user) { create(:user) }
|
|
||||||
|
|
||||||
describe '#create' do
|
|
||||||
it 'returns error if credentials are not corrent and does not set cookie' do
|
|
||||||
|
|
||||||
post create_endpoint, params: wrong_auth_params
|
|
||||||
|
|
||||||
expect(response).to be_successful
|
|
||||||
expect(response.body).to match record_not_found
|
|
||||||
expect(cookie_data).to eq nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends token and cookie if credentials are correct' do
|
|
||||||
post create_endpoint, params: correct_auth_params
|
|
||||||
|
|
||||||
expect(response).to be_successful
|
|
||||||
expect(response.body).not_to match record_not_found
|
|
||||||
expect(response.body).to match token_response
|
|
||||||
expect(cookie_data).not_to eq nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def wrong_auth_params
|
|
||||||
{
|
|
||||||
auth: {
|
|
||||||
email: 'wrong_email@api-test.com',
|
|
||||||
password: 'password'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def correct_auth_params
|
|
||||||
{
|
|
||||||
auth: {
|
|
||||||
email: current_user.email,
|
|
||||||
password: 'password'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_endpoint
|
|
||||||
'/api/v1/user_token'
|
|
||||||
end
|
|
||||||
|
|
||||||
def record_not_found
|
|
||||||
/Record not found/
|
|
||||||
end
|
|
||||||
|
|
||||||
def token_response
|
|
||||||
/jwt/
|
|
||||||
end
|
|
||||||
|
|
||||||
def cookie_data
|
|
||||||
cookies[:_easy_release_session]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -87,7 +87,7 @@ feature "User managing location releases" do
|
|||||||
|
|
||||||
visit new_account_project_contract_template_location_release_amendment_path(project.account, project, contract_template, release)
|
visit new_account_project_contract_template_location_release_amendment_path(project.account, project, contract_template, release)
|
||||||
|
|
||||||
expect(page).to have_content amendments_heading
|
expect(page).to have_content amendments_heading.upcase
|
||||||
|
|
||||||
fill_in amendment_signer_name_field, with: 'Big Signer'
|
fill_in amendment_signer_name_field, with: 'Big Signer'
|
||||||
draw_signature file_fixture("signature.png"), amendment_signature_field
|
draw_signature file_fixture("signature.png"), amendment_signature_field
|
||||||
@@ -250,7 +250,7 @@ feature "User managing location releases" do
|
|||||||
|
|
||||||
new_window = window_opened_by { click_link sign_amendment_link }
|
new_window = window_opened_by { click_link sign_amendment_link }
|
||||||
within_window new_window do
|
within_window new_window do
|
||||||
expect(page).to have_content amendments_heading
|
expect(page).to have_content amendments_heading.upcase
|
||||||
|
|
||||||
fill_in amendment_signer_name_field, with: 'Big Signer'
|
fill_in amendment_signer_name_field, with: 'Big Signer'
|
||||||
draw_signature file_fixture("signature.png"), amendment_signature_field
|
draw_signature file_fixture("signature.png"), amendment_signature_field
|
||||||
|
|||||||
Reference in New Issue
Block a user