[27260] Fix invitation token expiring (#6313)

https://community.openproject.com/wp/27260
Also fixes https://community.openproject.com/wp/27691

[ci skip]
pull/6322/head
Oliver Günther 7 years ago committed by GitHub
parent 60527f0500
commit 2ea8617079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/models/token/invitation.rb
  2. 3
      app/views/account/_register.html.erb
  3. 2
      app/views/account/register.html.erb
  4. 15
      spec/features/users/invitation_spec.rb

@ -37,7 +37,7 @@ module Token
##
# Invitation tokens are valid for one day.
def self.validity_time
Setting.invitation_expiration_days
(Setting.invitation_expiration_days || 1).days
end
##
@ -46,8 +46,6 @@ module Token
# their account using the expired token the activation will fail due to it being
# expired. A new invitation token will be generated which deletes the expired one
# implicitly.
def delete_expired_tokens
end
def delete_expired_tokens; end
end
end

@ -36,12 +36,13 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="op-modal--modal-header">
<%= homescreen_user_avatar %>
<h2><%= I18n.t('onboarding.welcome') %></h2>
<a class="dynamic-content-modal--close-button"
<a class="op-modal--modal-close-button dynamic-content-modal--close-button"
title="<%= t('js.close_popup_title') %>"
aria-label="<%= t('js.close_popup_title') %>">
<%= op_icon('icon-close') %>
</a>
</div>
<div class="op-modal--modal-body">
<h2><%= t(:label_register) %></h2>
<section class="form--section">

@ -27,7 +27,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<modal-wrapper initialize="true" modal-class-name="registration-modal modal-wrapper">
<modal-wrapper initialize="true" modal-class-name="registration-modal modal-wrapper -highlight">
<% @user ||= User.new %>
<%= render partial: '/account/register' %>
</modal-wrapper>

@ -28,7 +28,7 @@
require 'spec_helper'
feature 'resend invitation', type: :feature do
feature 'invitation spec', type: :feature, js: true do
let(:current_user) { FactoryBot.create :admin }
let(:user) { FactoryBot.create :invited_user, mail: 'holly@openproject.com' }
@ -40,7 +40,18 @@ feature 'resend invitation', type: :feature do
scenario 'admin resends the invitation' do
click_on I18n.t(:label_send_invitation)
expect(page).to have_text 'An invitation has been sent to holly@openproject.com.'
# Logout admin
logout
# Visit invitation with wrong token
visit account_activate_path(token: 'some invalid value')
expect(page).to have_text 'Invalid activation token'
# Visit invitation link with correct token
visit account_activate_path(token: Token::Invitation.last.value)
expect(page).to have_selector('.op-modal--modal-header', text: 'Welcome to OpenProject')
end
end
Loading…
Cancel
Save