match '/sign_in' => 'main#index'
 match '/log_in'  => 'main#index'
 devise_for :#{name_default_users} do
   get '/sign_in'  => 'main#index', :as => :new_user_session
 end
348374
def user_type_routes 
      user_types_to_route.each do |user_type|
        name_user_types = user_type.pluralize
        if read_routes_file =~ /devise_for :#{name_user_types}/          
          debug! "removing old devise routing for: #{name_user_types}"
          File.remove_content_from routes_file, :where => /devise_for :#{name_user_types}/
        end
      end

      debug! "performing devise role routing for: #{user_types_to_route}"

      user_types_to_route.map do |user_type| 
        name_user_types = user_type.pluralize     
        name_user_type = user_type.underscore.gsub('/', '_')
          %Q{            
  devise_for :#{name_user_types}, :class_name => '#{user_type.classify}', :controllers => {:registrations => 'devise/registrations', :sessions => 'main'} do
    match "/#{name_user_types}/sign_in" => "devise/sessions#new", :as => :#{name_user_type}_signin
    match "/#{name_user_types}/sign_up" => "devise/registrations#new", :as => :#{name_user_type}_signup
  end
  }
      end.join("\n")
    end
627012
def basic_auth(opts)
      user = opts.fetch :user
      pass = opts.fetch :pass

      auth("Basic " + Base64.strict_encode64("#{user}:#{pass}"))
    end
374799
def after_sign_out_path_for(resource_or_scope)

    if ::Milia.signout_to_root
      root_path        # return to index page
    else
        # or return to sign-in page
     scope = Devise::Mapping.find_scope!(resource_or_scope)
     send(:"new_#{scope}_session_path")
    end

  end
1210498
def default_login_checker(user):
    
    username = user.get('username')
    password = user.get('password')
    the_username = os.environ.get(
        'SIMPLELOGIN_USERNAME',
        current_app.config.get('SIMPLELOGIN_USERNAME', 'admin')
    )
    the_password = os.environ.get(
        'SIMPLELOGIN_PASSWORD',
        current_app.config.get('SIMPLELOGIN_PASSWORD', 'secret')
    )
    if username == the_username and password == the_password:
        return True
    return False
532331
def get_paged_search_results(params,user:nil,model:nil)
			params[:per_page] = 10 if params[:per_page].blank?
			params[:page] = 1 if params[:page].blank?
			# a ghetto user check, but for some reason a devise user is not a devise user...
			user = User.new if user.blank? or !user.class.to_s == User.to_s

			# get the model in question
			# there has got to be a better way to do this... I just can't find it
			# model = params[:controller].blank? ? self.class.name.gsub('Controller','').singularize.constantize : params[:controller].classify.constantize
			if model.blank? 
				model = request.params[:table_name].classify.constantize unless request.params[:table_name].blank?
				return nil if model.blank?
			end

			# initialize un-paged filtered result set
			result_set = model.none

			# create where clauses to filter result to just the customers the current user has access to
			customer_filter = ""
			user.customers.each do |cust|
				if model.column_names.include? "cust_id"
					customer_filter << "(cust_id = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
				elsif model.attribute_alias? "cust_id"
					customer_filter << "(#{model.attribute_alias "cust_id"} = '#{cust.cust_id(true)}') OR " unless cust.cust_id.blank?
				elsif model.column_names.include? "order_number"
					customer_filter << "(order_number like '#{cust.prefix}%') OR " unless cust.prefix.blank?
				elsif model.attribute_alias? "order_number"
					customer_filter << "(#{model.attribute_alias "order_number"} like '#{cust.prefix}%') OR " unless cust.prefix.blank?
				end
			end
			customer_filter << " (1=0)"

			# create where clauses for each search parameter
			if params[:columns].blank?
				result_set = model.where(customer_filter)
			else
				where_clause = ""
				params[:columns].each do |name, value|
					where_clause << "(#{model.table_name}.#{name} like '%#{value}%') AND " unless value.blank?
				end
				where_clause << " (1=1)"

				result_set = model.where(customer_filter).where(where_clause)
			end

			instances = model.paginate(page: params[:page], per_page: params[:per_page]).merge(result_set).order(updated_at: :desc)
			return {instances:instances,params:params}
		end
140007
async def login_user(self, password, **kwds):
        
        # find the matching user with the given email
        user_data = (await self._get_matching_user(fields=list(kwds.keys()), **kwds))['data']
        try:
            # look for a matching entry in the local database
            passwordEntry = self.model.select().where(
                self.model.user == user_data[root_query()][0]['pk']
            )[0]
        # if we couldn't acess the id of the result
        except (KeyError, IndexError) as e:
            # yell loudly
            raise RuntimeError('Could not find matching registered user')


        # if the given password matches the stored hash
        if passwordEntry and passwordEntry.password == password:
            # the remote entry for the user
            user = user_data[root_query()][0]
            # then return a dictionary with the user and sessionToken
            return {
                'user': user,
                'sessionToken': self._user_session_token(user)
            }

        # otherwise the passwords don't match
        raise RuntimeError("Incorrect credentials")
1033720
def signed_in?(options = {})
      options.reverse_merge!(as: :user)
      current_authenticated(options).present? && \
        current_authenticated(options).class.name.demodulize.underscore == options[:as].to_s
    end
1221898
public function it_is_match_standard()
    {
        $this->beConstructedWith([
            '/login' => 'user.login',
            'as' => 'login',
        ]);

        $this->matching('/login')->shouldBe(true);

        $this->getName()->shouldBe('login');
        $this->getController()->shouldBe('user');
        $this->getAction()->shouldBe('login');
    }
1194029
def current_user
      if (user_id = session[:user_id])
        @current_user ||= User.find_by(id: user_id)
      elsif (user_id = cookies.signed[:user_id])
        user = User.find_by(id: user_id)
        if user && user.authenticated?(cookies[:remember_token])
          log_in user
          @current_user = user
        end
      end
    end
702207
def login(user, password)
      data = request('authenticateUser',
                     { username: user, password: password },
                     true)
      @user = User.new(self, data)
      fail InvalidAuthentication, 'Wrong username or password!' if @user.id == 0

      @user
    end
131001
def creds(self):
        
        session = self.client.session()
        if session is None:
            return None

        return {
            "basic_auth": self.client.basic_auth_str(),
            "user_ctx": session.get('userCtx')
        }
188330
def check_basic_auth(self, username, password):
        
        valid = self.users.check_password(
            username, password
        )
        if not valid:
            log.warning('Invalid login from %s', username)
            valid = False
        return (
            valid,
            username
        )
617348
def match_user
      unless admin?
        user = User.find(current_user)

        unless user.id == set_user.id
          redirect_to user_path(current_user), notice: 'You do not have any permission to grant this page !'
        end
      end
    end
4060
def create
      if (@user = Incline::UserManager.authenticate(params[:session][:email], params[:session][:password], request.remote_ip))
        if @user.activated?
          # log the user in.
          log_in @user
          params[:session][:remember_me] == '1' ? remember(@user) : forget(@user)

          # show alerts on login.
          session[:show_alerts] = true

          redirect_back_or @user
        else
          flash[:safe_warning] = 'Your account has not yet been activated.<br/>Check your email for the activation link.'
          redirect_to main_app.root_url
        end
      else
        # deny login.
        flash.now[:danger] = 'Invalid email or password.'
        render 'new'
      end
    end
434192
def logout_method(user = current_user)
      http_method = security.logout_method
      http_method || if defined? ::Devise
                       scope = ::Devise::Mapping.find_scope! user
                       mapping = ::Devise.mappings[scope]
                       mapping.sign_out_via
                     end
    end
651215
def destroy
      redirect_path = after_sign_out_path_for(resource_name)
      signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
      set_flash_message :notice, :signed_out if signed_out

      # We actually need to hardcode this as Rails default responder doesn't
      # support returning empty response on GET request
      respond_to do |format|
        format.any(*navigational_formats) { redirect_to (params[:return_to] || redirect_path) }
        format.all do
          head :no_content
        end
      end
    end
424433
def login(email, password, opts = {})
      ensure_ready!
      opts = opts.merge(:email => email, :password => password)
      checked_response_body(connection.post('login', opts))
    end