mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-21 22:07:49 +00:00
Clean up error flow for sso
error messages can now propagate to the user's browser
This commit is contained in:
parent
e7fee4c6ce
commit
da179d9930
@ -1740,7 +1740,6 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
scode = 200;
|
scode = 200;
|
||||||
sprintf(resBuf, ssoResponseTemplate, "Authentication Successful. You may now access the network.");
|
sprintf(resBuf, ssoResponseTemplate, "Authentication Successful. You may now access the network.");
|
||||||
responseBody = std::string(resBuf);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not an object? We got a problem
|
// not an object? We got a problem
|
||||||
@ -1751,6 +1750,7 @@ public:
|
|||||||
zeroidc::free_cstr(code);
|
zeroidc::free_cstr(code);
|
||||||
zeroidc::free_cstr(ret);
|
zeroidc::free_cstr(ret);
|
||||||
|
|
||||||
|
responseBody = std::string(resBuf);
|
||||||
responseContentType = "text/html";
|
responseContentType = "text/html";
|
||||||
return scode;
|
return scode;
|
||||||
} else {
|
} else {
|
||||||
|
@ -247,11 +247,19 @@ pub extern "C" fn zeroidc_token_exchange(idc: *mut ZeroIDC, code: *const c_char)
|
|||||||
let ret = idc.do_token_exchange(code);
|
let ret = idc.do_token_exchange(code);
|
||||||
match ret {
|
match ret {
|
||||||
Ok(ret) => {
|
Ok(ret) => {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
println!("do_token_exchange ret: {}", ret);
|
||||||
|
}
|
||||||
let ret = CString::new(ret).unwrap();
|
let ret = CString::new(ret).unwrap();
|
||||||
ret.into_raw()
|
ret.into_raw()
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let errstr = format!("{{\"errorMessage\":\"{}\"\"}}", e);
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
println!("do_token_exchange err: {}", e);
|
||||||
|
}
|
||||||
|
let errstr = format!("{{\"errorMessage\": \"{}\"}}", e);
|
||||||
let ret = CString::new(errstr).unwrap();
|
let ret = CString::new(errstr).unwrap();
|
||||||
ret.into_raw()
|
ret.into_raw()
|
||||||
}
|
}
|
||||||
|
@ -579,6 +579,7 @@ impl ZeroIDC {
|
|||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
|
if res.status() == 200 {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
println!("hit url: {}", res.url().as_str());
|
println!("hit url: {}", res.url().as_str());
|
||||||
@ -630,6 +631,17 @@ impl ZeroIDC {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
|
} else {
|
||||||
|
if res.status() == 402 {
|
||||||
|
Err(SSOExchangeError::new(
|
||||||
|
"additional license seats required. Please contact your network administrator.".to_string(),
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Err(SSOExchangeError::new(
|
||||||
|
"error from central endpoint".to_string(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(res) => {
|
Err(res) => {
|
||||||
println!("error result: {}", res);
|
println!("error result: {}", res);
|
||||||
|
Loading…
Reference in New Issue
Block a user