<commit_before><?php
/**
 * Copyright 2016 <NAME> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

declare(strict_types = 1);

include_once "IStaticModule.php";

/**
 * Created by <NAME> (<EMAIL>) on 2016-10-14
 *
 */
class UIAuth implements IStaticModule {

	private static $session;

	public function __construct(Session $session) {
		self::$session = $session;
	}

	public static function isLoggedIn(): bool {
		return self::$session->isLoggedIn();
	}

	public static function PrintLogin() {
		self::isLoggedIn() ? print '<a class="br-auth" href="?logout">Log out</a>' : print '<a class="br-auth" href="?login">Log in</a>';
	}

	public static function PrintUserName() {
		if (!self::$session->isLoggedIn()) return;
		print '<a class="br-auth" href="?profile">'.self::$session->getLoggedInUser().'</a>';
	}

	public static function PrintLoginDialog() { ?>
		<form method="post" class="br-auth">
			<p><label for="br-username">Username:</label><input type="text" name="br-username" id="br-username" /></p>
			<p><label for="br-password">Password:</label><input type="password" name="br-password" id="br-password" /></p>
			<p><input type="submit" value="Log In" class="br-button" /></p>
		</form>
	<?php }

	function printContent() {
		if (!self::$session->isLoggedIn()) {
			self::PrintLoginDialog();
			return;
		}

		self::PrintUserName();
	}
}<commit_msg>Show feedback. Do not show login if auth is not available<commit_after><?php
/**
 * Copyright 2016 <NAME> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

declare(strict_types = 1);

include_once "IStaticModule.php";

/**
 * Created by <NAME> (<EMAIL>) on 2016-10-14
 *
 */
class UIAuth implements IStaticModule {

	private static $session;

	public function __construct(Session $session) {
		self::$session = $session;
	}

	public static function isLoggedIn(): bool {
		return self::$session->isLoggedIn();
	}

	public static function PrintLogin() {
		if (!self::$session->isAuthAvailable()) return;
		self::isLoggedIn() ? print '<a class="br-auth" href="?logout">Log out</a>' : print '<a class="br-auth" href="?login">Log in</a>';
	}

	public static function PrintUserName() {
		if (!self::$session->isLoggedIn()) return;
		print '<a class="br-auth" href="?profile">'.self::$session->getLoggedInUser().'</a>';
	}

	public static function PrintLoginDialog() { ?>
		<form method="post" class="br-auth">
			<p><?php if(self::$session->getState() == SessionState::LOGIN_FAILED): ?>Login failed<?php endif; ?></p>
			<p><label for="br-username">Username:</label><input type="text" name="br-username" id="br-username" /></p>
			<p><label for="br-password">Password:</label><input type="password" name="br-password" id="br-password" /></p>
			<p><input type="submit" value="Log In" class="br-button" /></p>
		</form>
	<?php }

	function printContent() {
		if (!self::$session->isLoggedIn()) {
			self::PrintLoginDialog();
			return;
		}

		self::PrintUserName();
	}
}
{'fraction_non_alphanumeric': 0.16624685138539042, 'fraction_numerical': 0.008564231738035265, 'mean_word_length': 4.585091420534458, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6913768', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1215, 'n_words': 366}