mirror of
				https://github.com/j-a-n/raspberrymatic-addon-rmupdate.git
				synced 2023-10-10 11:37:40 +00:00 
			
		
		
		
	Adapt to new session handling
This commit is contained in:
		| @@ -54,32 +54,18 @@ proc check_session {sid} { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| proc new_session {} { | ||||
| 	set request [::http::geturl "http://127.0.0.1/login.htm"] | ||||
| 	set location [get_http_header $request "location"] | ||||
| 	::http::cleanup $request | ||||
| 	if {![regexp {sid=@([0-9a-zA-Z]{10})@} $location match sid]} { | ||||
| 		error "Too many sessions" "Service Unavailable" 503 | ||||
| 	} | ||||
| 	return $sid | ||||
| } | ||||
|  | ||||
| proc login {username password} { | ||||
| 	set sid [new_session] | ||||
| 	 | ||||
| 	set request [::http::geturl "http://127.0.0.1/login.htm?sid=@$sid@" -query [::http::formatQuery tbUsername $username tbPassword $password]] | ||||
| 	set request [::http::geturl "http://127.0.0.1/login.htm" -query [::http::formatQuery tbUsername $username tbPassword $password]] | ||||
| 	set code [::http::code $request] | ||||
| 	set location [get_http_header $request "location"] | ||||
| 	::http::cleanup $request | ||||
| 	 | ||||
| 	if {[string first "500" $code] != -1} { | ||||
| 		rega_script "system.ClearSessionID(\"$sid\");" | ||||
| 		error "Invalid session" "Internal server error" 500 | ||||
| 	if {[string first "error" $location] != -1} { | ||||
| 		error "Invalid username oder password" "Unauthorized" 401 | ||||
| 	} | ||||
| 	 | ||||
| 	if {[string first "error" $location] != -1} { | ||||
| 		rega_script "system.ClearSessionID(\"$sid\");" | ||||
| 		error "Invalid username oder password" "Unauthorized" 401 | ||||
| 	if {![regexp {sid=@([0-9a-zA-Z]{10})@} $location match sid]} { | ||||
| 		error "Too many sessions" "Service Unavailable" 503 | ||||
| 	} | ||||
| 	return $sid | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user