Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/organizer_position_invites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def show
elsif @invite.rejected?
redirect_to root_path, flash: { error: "You’ve already rejected this invitation." }
end
rescue Pundit::NotAuthorizedError
if @invite.user != current_user
flash[:error] = "This invitation was sent to #{@invite.user.redacted_email}, but you are currently logged in as #{current_user.email }."
redirect_to root_path and return
end

raise
end

def accept
Expand Down
14 changes: 14 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,20 @@ def initials
words.any? ? words.map(&:first).join.upcase : name
end

# gary@hackclub.com → g***y@hackclub.com
# gt@hackclub.com → g*@hackclub.com
# g@hackclub.com → g@hackclub.com
def redacted_email
handle, domain = email.split("@")
redacted_handle =
if handle.length <= 2
handle[0] + "*" * (handle.length - 1)
else
"#{handle[0]}***#{handle[-1]}"
end
"#{redacted_handle}@#{domain}"
end

def pretty_phone_number
Phonelib.parse(self.phone_number).national
end
Expand Down