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
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:
if you want to save uniq value you can add something like this:
uniqueness on a special scope:
you can create your own special validation method if you like(for example):