Sha256: 8bddc026e0d9300202f572bc6a80b1eb646786d2cf1180eb7dc9453678283835
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Masks module Credentials # Checks for an :actor given a matching email. class Email < Masks::Credential checks :actor def lookup return if actor || !email actor = config.find_actor(session, email:) actor ||= config.build_actor( session, email:, nickname: generate_nickname(email) ) actor.signup = true actor end def maskup approve! if actor && email && valid? end private def email @email ||= [session_params[:email], session_params[:nickname]].find do |param| ValidateEmail.valid?(param) end end def generate_nickname(email) return email if !nickname_format || nickname_format.match?(email) parts = email.split("@") name = parts[0].gsub(/[^\w\d]/, "") prefix_nickname( "#{name.downcase.slice(0, 16)}#{SecureRandom.hex.slice(0, 8)}" ) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems