make invite link use REQUEST_URI

This commit is contained in:
Devin Howard 2015-11-03 22:22:53 +08:00
parent 8b456f5a31
commit 660ee52292
2 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,7 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
before_filter :get_invite_link
# this is for global login # this is for global login
include ContentHelper include ContentHelper
@ -47,7 +49,6 @@ private
current_user current_user
end end
def authenticated? def authenticated?
current_user current_user
end end
@ -55,5 +56,11 @@ private
def admin? def admin?
current_user && current_user.admin current_user && current_user.admin
end end
def get_invite_link
unsafe_uri = request.env["REQUEST_URI"]
valid_url = /^https?:\/\/([\w\.-]+)(:\d{1,5})?\/?$/
safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : "http://metamaps.cc/"
@invite_link = "#{safe_uri}join?code=#{current_user.code}"
end
end end

View file

@ -231,9 +231,8 @@
<p>As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.</p> <p>As a valued beta tester, you have the ability to invite your peers, colleagues and collaborators onto the platform.</p>
<p>Below is a personal invite link containing your unique access code, which can be used multiple times.</p> <p>Below is a personal invite link containing your unique access code, which can be used multiple times.</p>
<div id="joinCodesBox"> <div id="joinCodesBox">
<% mapper = current_user %> <p class="joinCodes"><%= @invite_link %>
<p class="joinCodes">http://metamaps.cc/join?code=<%= mapper.code %></p> <button class="button" onclick="Metamaps.GlobalUI.shareInvite('<%= @invite_link %>');">COPY INVITE LINK!</button>
<button class="button" onclick="Metamaps.GlobalUI.shareInvite('http://metamaps.cc/join?code=<%= mapper.code %>');">COPY INVITE LINK!</button>
</div> </div>
</div> </div>