我正在尝试使用HWIOAuthBundle配置我的oauth2服务器,我想澄清一下HWIOAuthBundle期望正确配置import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AdvancedSearchComponent } from './searches/advanced-search/advanced-search.component';
import { GuidedSearchComponent } from './searches/guided-search/guided-search.component';
import { QuickSearchComponent } from './searches/quick-search/quick-search.component';
const appRoutes: Routes = [
{ path: 'searches/advanced-search', component: AdvancedSearchComponent },
{ path: 'searches/guided-search', component: GuidedSearchComponent },
{ path: 'searches/quick-search', component: QuickSearchComponent },
{ path: '', redirectTo: "/searches/guided-search", pathMatch: 'full' }
];
export const appRoutingProviders: any[] = [
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
的响应?
我猜它期待一个json文件。那么,它的领域是什么? 如果你有链接,我会很高兴。
infos_url
谢谢;)
答案 0 :(得分:1)
我发现它是如何完成的!您必须为用户创建一个简单的API,如下所示:
路由:
# app/routing.yml
api_users:
pattern: /api/users.json
defaults: { _controller: AppOAuthServerBundle:User:getUser }
options:
i18n: false
控制器:
<?php
namespace App\OAuthServerBundle\Controller;
use App\GeneralBundle\Entity\User;
use FOS\RestBundle\Controller\FOSRestController;
class UserController extends FOSRestController
{
public function getUserAction()
{
$user = $this->get('security.context')->getToken()->getUser();
if ( $user instanceof User ) {
$data = array(
'id' => $user->getId(),
'username' => $user->getUsername(),
'realname' => $user->getFirstname().' '.$user->getLastname(),
'email' => $user->getEmail(),
);
} else {
$data = array();
}
$view = $this->view($data, 200)
->setTemplate('AppOAuthServerBundle:Default:index.html.twig')
->setFormat('json')
->setTemplateVar('user');
return $this->handleView($view);
}
}