當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Token::generateToken方法代碼示例

本文整理匯總了PHP中Token::generateToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP Token::generateToken方法的具體用法?PHP Token::generateToken怎麽用?PHP Token::generateToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Token的用法示例。


在下文中一共展示了Token::generateToken方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

					</div>
				</div>
				<hr id="login-hr">
				<div class="ui login form">
					<form class="login-form" method="post">
						<div class="field username">
							<label>Username</label>
							<input type="text" id="username" name="username" placeholder="Username">
							<p class="note">You can login with your username, email or id.</p>
						</div>
						<div class="field password">
							<label>Password</label>
							<input type="password" name="password" placeholder="Password">
						</div>
							<br>
							<button class="ui button green submit" type="submit">Log in</button>
						<input type="hidden" name="auth_token" value="<?php 
echo Token::generateToken();
?>
" />
					</form>
				</div>
			</div>
		</div>
	</div>
<script src="/scripts/auth.js"></script>
<?php 
include ROOT_PATH . 'inc/footer.php';
?>
</body>
</html>
開發者ID:khaledkhalil94,項目名稱:SH.A,代碼行數:31,代碼來源:login.php

示例2: install

 static function install()
 {
     $token = Token::generateToken();
     add_option('watchtower', array('access_token' => $token));
     flush_rewrite_rules();
 }
開發者ID:c2pdev,項目名稱:WatchTower_Client,代碼行數:6,代碼來源:class-install-uninstall.php

示例3: access_token_callback

 /**
  *
  */
 public function access_token_callback()
 {
     printf('<input type="hidden" id="access_token" name="watchtower[access_token]" value="' . Token::generateToken() . '" />', isset($this->options['access_token']) ? esc_attr($this->options['access_token']) : '');
 }
開發者ID:c2pdev,項目名稱:WatchTower_Client,代碼行數:7,代碼來源:class-watchtower.php

示例4: User

    }
    // Check if username exists
    if (User::where('nickname', 'like', $req_body->nickname)->count()) {
        $app->halt(400, 'nickname_exists');
    }
    try {
        $user = new User();
        $user->nickname = $req_body->nickname;
        $user->gender = $req_body->gender;
        $user->password = sha1($req_body->password1);
        $user->educationLevel()->associate(EducationLevel::find((int) $req_body->schoolAdvice));
        $user->school()->associate(School::find((int) $req_body->school));
        $user->save();
        // Create token
        $token = new Token();
        $token->generateToken();
        $token->user()->associate($user);
        $token->save();
    } catch (Exception $e) {
        $app->halt(500, 'something_went_wrong');
    }
    echo $token->toJson();
});
$app->get('/user', function () use($app) {
    $app->response()->header('Content-Type', 'application/json');
    $token_key = $app->request->headers->get('Authorization');
    try {
        $user = User::with('talents', 'token')->whereHas('token', function ($q) use($token_key) {
            $q->where('key', '=', $token_key);
        })->firstOrFail();
    } catch (ModelNotFoundException $e) {
開發者ID:Robinwist,項目名稱:UXDTalentenTest,代碼行數:31,代碼來源:api.php


注:本文中的Token::generateToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。