1
class OpenAMStrategy < Base
        def valid? 
            puts("*************** CHECKING OPEN AM VALID ABXXXAB ********")                
            request.headers['uid'].present?
            return true
        end

Here i need to add validation after open AM authentication if user present in database it should login ,otherwise it had to show some error message

def authenticate!
            puts("******************** DOING OPEN AM AUTHENTICATE ----")
            userName = uidHeader
            user = User.find_by_email(userName)
            if user
            request.headers.env.select do |k, _| 
                k.downcase.start_with?('http') ||
                k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES)
                headerValue = _ if k.downcase.starts_with?('http')
                puts("************  HEADER >>>> #{k} VALUE --> #{headerValue}")
            end
invisible
  • 11
  • 4

1 Answers1

1

I'm thinking this guide is useful for you:

In creation process, if username has to present you can add this code to your model:

validates :username, presence: true

if you want to save uniq value you can add something like this:

validates :username, presence: true, uniqueness: true

uniqueness on a special scope:

validates :username, presence: true, uniqueness: { scope: :account_id }

you can create your own special validation method if you like(for example):

validate :check_valid_last_name


def check_valid_last_name
    # your special code 
    #  ...
    #  return something
end