Returns a truthy value if we came from a devise URL like users/sign_in
490656
def referrer_is_a_devise_url?
      referrer = request.referer
      return if request.blank? || referrer.blank?

      regex_defining_devise_paths = %r{(#{new_user_session_path}|users\/password|users\/sign_up)}
      URI.parse(referrer).path =~ regex_defining_devise_paths
    end
902366
def get_authorize_url(self, **params):
        '''
        
        '''
        params = self.session_obj.sign(self.authorize_url,
                                       self.app_id,
                                       self.app_secret,
                                       **params)
        return self.authorize_url + '?' + params
91114
def password_required?
      # TODO: nil? is not suitable for here we should use empty? or blink?
      if Devise.omniauth_configs.any?
        return (provider.nil? || password.nil?) && super
      else
        password.nil? && super
      end
    end
316852
def valid(self):
        
        two_legged = self.client_email and self.private_key
        three_legged = self.client_id and self.client_secret
        return two_legged or three_legged or False
628381
def scope_url
      opts  = {}
      route = route(scope)
      opts[:format] = request_format unless skip_format?

      config = Rails.application.config

      # Monkey Patch
      if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
        opts[:script_name] = config.relative_url_root
      end
      # EO Monkey Patch

      router_name = Devise.mappings[scope].router_name || Devise.available_router_name
      context = send(router_name)

      if context.respond_to?(route)
        context.send(route, opts)
      elsif respond_to?(:root_url)
        root_url(opts)
      else
        "/"
      end
    end
1106624
def checkURL(cls, trust_root, url):
        """"""
        tr = cls.parse(trust_root)
        return tr is not None and tr.validateURL(url)
612420
def get_state(self, as_str=False):
        

        uid = self.user_id

        if self._iface_user.get_id() == uid:
            result = self._iface.get_my_state()

        else:
            result = self._iface.get_state(uid)

        if as_str:
            return UserState.get_alias(result)

        return result
806947
def finalize_with_devise!
      result = finalize_without_devise!

      @devise_finalized ||= begin
        if Devise.router_name.nil? && defined?(@devise_finalized) && self != Rails.application.try(:routes)
          warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
            "In this case, you probably want to set Devise.router_name = MOUNT_POINT, where "   \
            "MOUNT_POINT is a symbol representing where this engine will be mounted at. For "   \
            "now Devise will default the mount point to :main_app. You can explicitly set it"   \
            " to :main_app as well in case you want to keep the current behavior."
        end

        Devise.configure_warden!
        Devise.regenerate_helpers!
        true
      end

      result
    end
867608
def password_archivable
      apply_devise_schema :encrypted_password, String, limit: 128, null: false
      apply_devise_schema :password_salt, String
      apply_devise_schema :password_archivable_id, Integer, null: false
      apply_devise_schema :password_archivable_type, String, null: false
      apply_devise_schema :created_at, DateTime
    end
558700
def trusted=(val)
      if ! [ true, false ].include?(val)
        raise ArgumentError, "value must be a boolean"
      end
      @o_dev[I_DEVICE]['Trusted'] = val
    end
490420
def authenticate
      # Take the user id (eg integer 1000) make a string out of it "1000", take
      # each character and determin hex value "1" => 0x31, "0" => 0x30. You
      # obtain for "1000" => 31303030 This is what the server is expecting.
      # Why? I dunno. How did I come to that conclusion? by looking at rbus
      # code. I have no idea how he found that out.
      Process.uid.to_s.split(//).map { |d| d.ord.to_s(16) }.join
    end
47226
def user_exists?(username)
      begin
        url = url_for_path(user_path(username))
        client.get(url) { |response| response.code == 200 }
      rescue
        raise 'Error: Could not test user existence!'
      end
    end
722296
def get_authenticity_token(self, url=_SIGNIN_URL):
        
        res = self.client._get(url=url, expected_status_code=200)
        soup = BeautifulSoup(res.text, _DEFAULT_BEAUTIFULSOUP_PARSER)
        selection = soup.select(_AUTHENTICITY_TOKEN_SELECTOR)
        try:
            authenticity_token = selection[0].get("content")
        except:
            raise ValueError(
                "authenticity_token not found in {} with {}\n{}".format(
                 _SIGNIN_URL, _AUTHENTICITY_TOKEN_SELECTOR, res.text))
        return authenticity_token
658917
def authenticated_userid(request):
    
    user = getattr(request, 'user', None)
    key = user.pk_field()
    return getattr(user, key)
1212688
def rights(self, form, load):
        '''
        
        '''

        adata = self.auth_data
        good = False
        if load.get('token', False):
            for sub_auth in self.token(self.auth_data, load):
                if sub_auth:
                    if self.rights_check(
                            form,
                            self.auth_data[sub_auth['token']['eauth']],
                            sub_auth['token']['name'],
                            load,
                            sub_auth['token']['eauth']):
                        return True
            log.warning(
                'Authentication failure of type "token" occurred.'
            )
        elif load.get('eauth'):
            for sub_auth in self.eauth(self.auth_data, load):
                if sub_auth:
                    if self.rights_check(
                            form,
                            sub_auth['sub_auth'],
                            sub_auth['name'],
                            load,
                            load['eauth']):
                        return True
            log.warning(
                'Authentication failure of type "eauth" occurred.'
            )
        return False
204057
def show
    if @confirmable.new_record?  ||
       !::Milia.use_invite_member ||
       @confirmable.skip_confirm_change_password

      log_action( "devise pass-thru" )
      super  # this will redirect
      if @confirmable.skip_confirm_change_password
        sign_in_tenanted(resource)
      end
    else
      log_action( "password set form" )
      prep_do_show()  # prep for the form
    end
    # else fall thru to show template which is form to set a password
    # upon SUBMIT, processing will continue from update
  end
1006180
def isSigned(self, ns_uri, ns_key):
        
        return self.message.getKey(ns_uri, ns_key) in self.signed_fields