()
| 221 | }, [userdata]); |
| 222 | |
| 223 | const checkLogin = () => { |
| 224 | var baseurl = globalUrl; |
| 225 | fetch(`${globalUrl}/api/v1/getinfo`, { |
| 226 | credentials: "include", |
| 227 | headers: { |
| 228 | "Content-Type": "application/json", |
| 229 | }, |
| 230 | }) |
| 231 | .then((response) => response.json()) |
| 232 | .then((responseJson) => { |
| 233 | var userInfo = {}; |
| 234 | if (responseJson.success === true) { |
| 235 | //console.log("USER: ", responseJson); |
| 236 | if (responseJson?.switch_parent === true) { |
| 237 | toast.info(responseJson.reason) |
| 238 | setTimeout(() => { |
| 239 | window.location.reload(); |
| 240 | }, 3000); |
| 241 | return |
| 242 | } |
| 243 | |
| 244 | userInfo = responseJson; |
| 245 | setIsLoggedIn(true); |
| 246 | //console.log("Cookies: ", cookies) |
| 247 | // Updating cookie every request |
| 248 | for (var key in responseJson["cookies"]) { |
| 249 | setCookie( |
| 250 | responseJson["cookies"][key].key, |
| 251 | responseJson["cookies"][key].value, |
| 252 | { path: "/" } |
| 253 | ); |
| 254 | } |
| 255 | if (responseJson?.org_status?.includes("integration_partner")) { |
| 256 | if (responseJson?.active_org?.branding?.enable_chat !== true) { |
| 257 | |
| 258 | // Find the drift chatbox and remove it |
| 259 | } |
| 260 | |
| 261 | if (responseJson?.active_org?.branding?.theme?.length > 0 ) { |
| 262 | handleThemeChange(responseJson?.active_org?.branding?.theme) |
| 263 | } |
| 264 | |
| 265 | if (responseJson?.active_org?.branding?.brand_color?.length > 0 ) { |
| 266 | setBrandColor(responseJson?.active_org?.branding?.brand_color) |
| 267 | localStorage.setItem("brandColor", responseJson?.active_org?.branding?.brand_color) |
| 268 | } |
| 269 | |
| 270 | if (responseJson?.active_org?.branding?.brand_name?.length > 0 ) { |
| 271 | setBrandName(responseJson?.active_org?.branding?.brand_name) |
| 272 | localStorage.setItem("brandName", responseJson?.active_org?.branding?.brand_name) |
| 273 | } |
| 274 | |
| 275 | if (responseJson?.active_org?.branding?.support_email?.length > 0 ) { |
| 276 | setSupportEmail(responseJson?.active_org?.branding?.support_email) |
| 277 | } |
| 278 | |
| 279 | if (responseJson?.active_org?.branding?.logout_url?.length > 0 ) { |
| 280 | setLogoutUrl(responseJson?.active_org?.branding?.logout_url) |
no test coverage detected