@Override
		public void run()
		{
			log.info("working");
			Map<String, Object> data = new HashMap<>();
			boolean redirect = false;
			String target = "/orders";
			String token = rx.cookieValue("CPA");
			int authorizedAs = -1;
			if(rx.method().equals("POST"))
			{
				String login = rx.postParam("inputEmail");
				String password = rx.postParam("inputPassword");
				target = rx.postParam("back_url");
				authorizedAs = AuthorizationService.authorized(login, password);
			}
			else if(token != null)
				authorizedAs = AuthorizationService.authorized(token);

			if(authorizedAs > 0)
			{
				token = BitrixAuthorizationRepository.i().generateToken();
				SessionsCache.put(token, authorizedAs);
				tx.cookie(CookieService.i().setCookie("CPA", token));
				redirect = true;
			}
			else
				data.put("error",true);
			if(redirect)
			{
				// Status should be something like 303 because we need to change request type to GET from whatever
				tx.status(303);
				tx.header("Location", target == null ? "/orders" : target);
			}
			else
			{
				Handlebars h = new MyHandlebars();
				Context c = Context
					.newBuilder(data)
					.resolver(FieldValueResolver.INSTANCE, MapValueResolver.INSTANCE, MethodValueResolver.INSTANCE)
					.build();
				try
				{
					Template t = h.compile("login");
					String s = t.apply(c);
					tx.content(s);
				}
				catch(Exception e)
				{
					log.error(e.toString(), e);
				}
				tx.status(200);
			}
			tx.end();
		}