in pan-domain-auth-verification/src/main/scala/com/gu/pandomainauth/PanDomain.scala [46:75]
private def checkStatus(authedUser: AuthenticatedUser, validateUser: AuthenticatedUser => Boolean,
apiGracePeriod: Duration, system: String, cacheValidation: Boolean,
forceExpiry: Boolean): AuthenticationStatus = {
if (authedUser.isExpired && authedUser.isInGracePeriod(apiGracePeriod)) {
// expired, but in grace period - check user is valid, GracePeriod if so
if (cacheValidation && authedUser.authenticatedIn(system)) {
// if validation is cached, check user has been validated here
GracePeriod(authedUser)
} else if (validateUser(authedUser)) {
// validation says this user is ok
GracePeriod(authedUser)
} else {
// the user is in the grace period but has failed validation
NotAuthorized(authedUser)
}
} else if (authedUser.isExpired || forceExpiry) {
// expired and outside grace period
Expired(authedUser)
} else if (cacheValidation && authedUser.authenticatedIn(system)) {
// if cacheValidation is enabled, check the user was validated here
Authenticated(authedUser)
} else if (validateUser(authedUser)) {
// fresh validation says the user is valid
Authenticated(authedUser)
} else {
// user has not expired but has failed validation checks
NotAuthorized(authedUser)
}
}