#NEWLINE# def validate_hour( self ) : #NEWLINE# #INDENT# 'check if user is logging in during restricted hours' #NEWLINE# login_before = int ( ( frappe . db . get_value ( 'User' , self . user , 'login_before' , ignore = True ) or 0 ) ) #NEWLINE# login_after = int ( ( frappe . db . get_value ( 'User' , self . user , 'login_after' , ignore = True ) or 0 ) ) #NEWLINE# if ( not ( login_before or login_before ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# from frappe.utils import now_datetime #NEWLINE# current_hour = int ( now_datetime ( ) . strftime ( '%H' ) ) #NEWLINE# if ( login_before and ( current_hour > login_before ) ) : #NEWLINE# #INDENT# frappe . throw ( _ ( 'Login not allowed at this time' ) , frappe . AuthenticationError ) #NEWLINE# #UNINDENT# if ( login_after and ( current_hour < login_after ) ) : #NEWLINE# #INDENT# frappe . throw ( _ ( 'Login not allowed at this time' ) , frappe . AuthenticationError )