mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: update connector page
This commit is contained in:
@@ -1,8 +1,124 @@
|
|||||||
import {FormInstance} from "antd";
|
import {Button, Form, FormInstance, Input, Select, Space, Typography} from "antd";
|
||||||
import React from "react";
|
import React, {useState} from "react";
|
||||||
import {Connector} from "../../utils/api/connectors";
|
import {Connector, ConnectorProvider} from "../../utils/api/connectors";
|
||||||
|
import {t} from "ttag";
|
||||||
|
import {BankOutlined} from "@ant-design/icons";
|
||||||
|
import {regionNames} from "../../i18n";
|
||||||
|
|
||||||
|
const formItemLayoutWithOutLabel = {
|
||||||
|
wrapperCol: {
|
||||||
|
xs: {span: 24, offset: 0},
|
||||||
|
sm: {span: 20, offset: 4},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) {
|
export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) {
|
||||||
return <>
|
const [provider, setProvider] = useState<string>()
|
||||||
</>
|
|
||||||
|
const ovhFields = {
|
||||||
|
appKey: t`Application key`,
|
||||||
|
appSecret: t`Application secret`,
|
||||||
|
consumerKey: t`Consumer key`
|
||||||
|
}
|
||||||
|
|
||||||
|
const ovhEndpointList = [
|
||||||
|
{
|
||||||
|
label: t`European Region`,
|
||||||
|
value: 'ovh-eu'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const ovhSubsidiaryList = [{value: 'EU', label: t`Europa`}, ...[
|
||||||
|
'CZ', 'DE', 'ES', 'FI', 'FR', 'GB', 'IE', 'IT', 'LT', 'MA', 'NL', 'PL', 'PT', 'SN', 'TN'
|
||||||
|
].map(c => ({value: c, label: regionNames.of(c) ?? c}))]
|
||||||
|
|
||||||
|
const ovhPricingMode = [
|
||||||
|
{value: 'create-default', label: t`The domain is free and at the standard price`},
|
||||||
|
{
|
||||||
|
value: 'create-premium',
|
||||||
|
label: t`The domain is free but is a premium. Its price varies from one domain to another`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return <Form
|
||||||
|
{...formItemLayoutWithOutLabel}
|
||||||
|
form={form}
|
||||||
|
layout="horizontal"
|
||||||
|
labelCol={{span: 6}}
|
||||||
|
wrapperCol={{span: 14}}
|
||||||
|
onFinish={onCreate}
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
label={t`Provider`}
|
||||||
|
name="provider"
|
||||||
|
rules={[{required: true, message: t`Required`}]}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
placeholder={t`Please select a Provider`}
|
||||||
|
suffixIcon={<BankOutlined/>}
|
||||||
|
options={Object.keys(ConnectorProvider).map((c) => ({
|
||||||
|
value: ConnectorProvider[c as keyof typeof ConnectorProvider],
|
||||||
|
label: (
|
||||||
|
<>
|
||||||
|
<BankOutlined/>{" "} {c}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
}))}
|
||||||
|
value={provider}
|
||||||
|
onChange={setProvider}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
{
|
||||||
|
provider === ConnectorProvider.OVH && <>
|
||||||
|
<Typography.Link target='_blank'
|
||||||
|
href="https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*">
|
||||||
|
Retrieve a token set from the OVH API
|
||||||
|
</Typography.Link>
|
||||||
|
{
|
||||||
|
Object.keys(ovhFields).map(fieldName => <Form.Item
|
||||||
|
label={ovhFields[fieldName as keyof typeof ovhFields]}
|
||||||
|
name={['authData', fieldName]}
|
||||||
|
rules={[{required: true, message: t`Required`}]}
|
||||||
|
>
|
||||||
|
<Input/>
|
||||||
|
</Form.Item>)
|
||||||
|
}
|
||||||
|
<Form.Item
|
||||||
|
label={t`OVH Endpoint`}
|
||||||
|
name={['authData', 'apiEndpoint']}
|
||||||
|
rules={[{required: true, message: t`Required`}]}
|
||||||
|
>
|
||||||
|
<Select options={ovhEndpointList} optionFilterProp="label"/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label={t`OVH subsidiary`}
|
||||||
|
name={['authData', 'ovhSubsidiary']}
|
||||||
|
rules={[{required: true, message: t`Required`}]}
|
||||||
|
>
|
||||||
|
<Select options={ovhSubsidiaryList} optionFilterProp="label"/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label={t`OVH pricing mode`}
|
||||||
|
name={['authData', 'pricingMode']}
|
||||||
|
rules={[{required: true, message: t`Required`}]}
|
||||||
|
>
|
||||||
|
<Select options={ovhPricingMode} optionFilterProp="label"/>
|
||||||
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<Form.Item style={{marginTop: 10}}>
|
||||||
|
<Space>
|
||||||
|
<Button type="primary" htmlType="submit">
|
||||||
|
{t`Create`}
|
||||||
|
</Button>
|
||||||
|
<Button type="default" htmlType="reset">
|
||||||
|
{t`Reset`}
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import {Button, Form, FormInstance, Input, Select, Space} from "antd";
|
import {Button, Form, FormInstance, Input, Select, Space} from "antd";
|
||||||
import {t} from "ttag";
|
import {t} from "ttag";
|
||||||
import {MinusCircleOutlined, PlusOutlined, ThunderboltFilled} from "@ant-design/icons";
|
import {MinusCircleOutlined, PlusOutlined, ThunderboltFilled} from "@ant-design/icons";
|
||||||
import React from "react";
|
import React, {useState} from "react";
|
||||||
import {EventAction} from "../../utils/api";
|
import {EventAction} from "../../utils/api";
|
||||||
|
import {Connector} from "../../utils/api/connectors";
|
||||||
|
|
||||||
|
|
||||||
const formItemLayout = {
|
const formItemLayout = {
|
||||||
@@ -23,8 +24,9 @@ const formItemLayoutWithOutLabel = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function WatchlistForm({form, onCreateWatchlist}: {
|
export function WatchlistForm({form, connectors, onCreateWatchlist}: {
|
||||||
form: FormInstance,
|
form: FormInstance,
|
||||||
|
connectors: (Connector & { id: string })[]
|
||||||
onCreateWatchlist: (values: { domains: string[], triggers: { event: string, action: string }[] }) => void
|
onCreateWatchlist: (values: { domains: string[], triggers: { event: string, action: string }[] }) => void
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
@@ -67,12 +69,17 @@ export function WatchlistForm({form, onCreateWatchlist}: {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const trigerActionItems = [
|
const triggerActionItems = [
|
||||||
{
|
{
|
||||||
label: t`Send me an email`,
|
label: t`Send me an email`,
|
||||||
value: 'email'
|
value: 'email'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t`Buy the domain if available`,
|
||||||
|
value: 'buy'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
const [actionsSelect, setActionsSelect] = useState<{ [key: number]: string }>({})
|
||||||
|
|
||||||
return <Form
|
return <Form
|
||||||
{...formItemLayoutWithOutLabel}
|
{...formItemLayoutWithOutLabel}
|
||||||
@@ -159,7 +166,6 @@ export function WatchlistForm({form, onCreateWatchlist}: {
|
|||||||
required={true}
|
required={true}
|
||||||
key={field.key}
|
key={field.key}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Form.Item {...field}
|
<Form.Item {...field}
|
||||||
validateTrigger={['onChange', 'onBlur']}
|
validateTrigger={['onChange', 'onBlur']}
|
||||||
@@ -178,13 +184,31 @@ export function WatchlistForm({form, onCreateWatchlist}: {
|
|||||||
message: t`Required`
|
message: t`Required`
|
||||||
}]}
|
}]}
|
||||||
noStyle name={[field.name, 'action']}>
|
noStyle name={[field.name, 'action']}>
|
||||||
<Select style={{minWidth: 300}} options={trigerActionItems} showSearch
|
<Select style={{minWidth: 300}} options={triggerActionItems} showSearch
|
||||||
placeholder={t`Then do that`}
|
placeholder={t`Then do that`}
|
||||||
optionFilterProp="label"/>
|
optionFilterProp="label" value={actionsSelect[field.key]}
|
||||||
|
onChange={(e) => setActionsSelect({...actionsSelect, [field.key]: e})}/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{actionsSelect[field.key] === 'buy' && <Form.Item {...field}
|
||||||
|
validateTrigger={['onChange', 'onBlur']}
|
||||||
|
rules={[{
|
||||||
|
required: true,
|
||||||
|
message: t`Required`
|
||||||
|
}]}
|
||||||
|
noStyle
|
||||||
|
name={[field.name, 'connector']}>
|
||||||
|
<Select style={{minWidth: 500}} showSearch
|
||||||
|
placeholder={t`Connector`}
|
||||||
|
optionFilterProp="label"
|
||||||
|
options={connectors.map(c => ({
|
||||||
|
label: `${c.provider} (${c.id})`,
|
||||||
|
value: c.id
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
}
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
|
|
||||||
{fields.length > 1 ? (
|
{fields.length > 1 ? (
|
||||||
<MinusCircleOutlined
|
<MinusCircleOutlined
|
||||||
className="dynamic-delete-button"
|
className="dynamic-delete-button"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
|
|||||||
onConfirm={() => deleteWatchlist(watchlist.token).then(onDelete)}
|
onConfirm={() => deleteWatchlist(watchlist.token).then(onDelete)}
|
||||||
okText={t`Yes`}
|
okText={t`Yes`}
|
||||||
cancelText={t`No`}
|
cancelText={t`No`}
|
||||||
><DeleteFilled/> </Popconfirm>}>
|
><DeleteFilled/></Popconfirm>}>
|
||||||
<Typography.Paragraph>
|
<Typography.Paragraph>
|
||||||
{t`Domain name`} : {watchlist?.domains.map(d => d.ldhName).join(',')}
|
{t`Domain name`} : {watchlist?.domains.map(d => d.ldhName).join(',')}
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {addLocale, useLocale} from 'ttag'
|
import {addLocale, useLocale} from 'ttag'
|
||||||
|
|
||||||
const locale = navigator.language.split('-')[0];
|
const locale = navigator.language.split('-')[0]
|
||||||
|
export const regionNames = new Intl.DisplayNames([locale], {type: 'region'})
|
||||||
|
|
||||||
if (locale !== 'en') {
|
if (locale !== 'en') {
|
||||||
fetch(`/locales/${locale}.po.json`).then(response => {
|
fetch(`/locales/${locale}.po.json`).then(response => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, {useEffect, useState} from "react";
|
|||||||
import {Collapse, Divider, Table, Typography} from "antd";
|
import {Collapse, Divider, Table, Typography} from "antd";
|
||||||
import {getTldList, Tld} from "../../utils/api";
|
import {getTldList, Tld} from "../../utils/api";
|
||||||
import {t} from 'ttag'
|
import {t} from 'ttag'
|
||||||
|
import {regionNames} from "../../i18n";
|
||||||
|
|
||||||
const {Text, Paragraph} = Typography
|
const {Text, Paragraph} = Typography
|
||||||
|
|
||||||
@@ -23,10 +24,6 @@ const getCountryCode = (tld: string): string => {
|
|||||||
return tld
|
return tld
|
||||||
}
|
}
|
||||||
|
|
||||||
const locale = navigator.language.split('-')[0]
|
|
||||||
const regionNames = new Intl.DisplayNames([locale], {type: 'region'})
|
|
||||||
|
|
||||||
|
|
||||||
function TldTable(filters: FiltersType) {
|
function TldTable(filters: FiltersType) {
|
||||||
const [dataTable, setDataTable] = useState<Tld[]>([])
|
const [dataTable, setDataTable] = useState<Tld[]>([])
|
||||||
const [total, setTotal] = useState(0)
|
const [total, setTotal] = useState(0)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import {Card, Flex, Form, message, Skeleton} from "antd";
|
import {Card, Flex, Form, message, Skeleton} from "antd";
|
||||||
import {t} from "ttag";
|
import {t} from "ttag";
|
||||||
import {Connector, getConnectors} from "../../utils/api/connectors";
|
import {Connector, getConnectors, postConnector} from "../../utils/api/connectors";
|
||||||
import {ConnectorForm} from "../../components/tracking/ConnectorForm";
|
import {ConnectorForm} from "../../components/tracking/ConnectorForm";
|
||||||
import {AxiosError} from "axios";
|
import {AxiosError} from "axios";
|
||||||
import {ConnectorsList} from "../../components/tracking/ConnectorsList";
|
import {ConnectorsList} from "../../components/tracking/ConnectorsList";
|
||||||
@@ -13,6 +13,16 @@ export default function ConnectorsPage() {
|
|||||||
const [messageApi, contextHolder] = message.useMessage()
|
const [messageApi, contextHolder] = message.useMessage()
|
||||||
const [connectors, setConnectors] = useState<ConnectorElement[] | null>()
|
const [connectors, setConnectors] = useState<ConnectorElement[] | null>()
|
||||||
|
|
||||||
|
const onCreateConnector = (values: Connector) => {
|
||||||
|
postConnector(values).then((w) => {
|
||||||
|
form.resetFields()
|
||||||
|
refreshConnectors()
|
||||||
|
messageApi.success(t`Connector created !`)
|
||||||
|
}).catch((e: AxiosError) => {
|
||||||
|
const data = e?.response?.data as { detail: string }
|
||||||
|
messageApi.error(data.detail ?? t`An error occurred`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const refreshConnectors = () => getConnectors().then(c => {
|
const refreshConnectors = () => getConnectors().then(c => {
|
||||||
setConnectors(c['hydra:member'])
|
setConnectors(c['hydra:member'])
|
||||||
@@ -28,10 +38,9 @@ export default function ConnectorsPage() {
|
|||||||
|
|
||||||
|
|
||||||
return <Flex gap="middle" align="center" justify="center" vertical>
|
return <Flex gap="middle" align="center" justify="center" vertical>
|
||||||
<Card title={t`Create a Connector`} style={{width: '100%'}} loading={true}>
|
<Card title={t`Create a Connector`} style={{width: '100%'}}>
|
||||||
{contextHolder}
|
{contextHolder}
|
||||||
<ConnectorForm form={form} onCreate={() => {
|
<ConnectorForm form={form} onCreate={onCreateConnector}/>
|
||||||
}}/>
|
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {AxiosError} from "axios";
|
|||||||
import {t} from 'ttag'
|
import {t} from 'ttag'
|
||||||
import {WatchlistForm} from "../../components/tracking/WatchlistForm";
|
import {WatchlistForm} from "../../components/tracking/WatchlistForm";
|
||||||
import {WatchlistsList} from "../../components/tracking/WatchlistsList";
|
import {WatchlistsList} from "../../components/tracking/WatchlistsList";
|
||||||
|
import {Connector, getConnectors} from "../../utils/api/connectors";
|
||||||
|
|
||||||
|
|
||||||
type Watchlist = { token: string, domains: { ldhName: string }[], triggers?: { event: EventAction, action: string }[] }
|
type Watchlist = { token: string, domains: { ldhName: string }[], triggers?: { event: EventAction, action: string }[] }
|
||||||
@@ -14,10 +15,18 @@ export default function WatchlistPage() {
|
|||||||
const [form] = Form.useForm()
|
const [form] = Form.useForm()
|
||||||
const [messageApi, contextHolder] = message.useMessage()
|
const [messageApi, contextHolder] = message.useMessage()
|
||||||
const [watchlists, setWatchlists] = useState<Watchlist[] | null>()
|
const [watchlists, setWatchlists] = useState<Watchlist[] | null>()
|
||||||
|
const [connectors, setConnectors] = useState<(Connector & { id: string })[] | null>()
|
||||||
|
|
||||||
const onCreateWatchlist = (values: { domains: string[], triggers: { event: string, action: string }[] }) => {
|
const onCreateWatchlist = (values: {
|
||||||
|
domains: string[],
|
||||||
|
triggers: { event: string, action: string, connector?: string }[]
|
||||||
|
}) => {
|
||||||
const domainsURI = values.domains.map(d => '/api/domains/' + d)
|
const domainsURI = values.domains.map(d => '/api/domains/' + d)
|
||||||
postWatchlist(domainsURI, values.triggers).then((w) => {
|
postWatchlist(domainsURI, values.triggers.map(({action, event, connector}) => ({
|
||||||
|
action,
|
||||||
|
event,
|
||||||
|
connector: connector !== undefined ? '/api/connectors/' + connector : undefined
|
||||||
|
}))).then((w) => {
|
||||||
form.resetFields()
|
form.resetFields()
|
||||||
refreshWatchlists()
|
refreshWatchlists()
|
||||||
messageApi.success(t`Watchlist created !`)
|
messageApi.success(t`Watchlist created !`)
|
||||||
@@ -37,12 +46,16 @@ export default function WatchlistPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshWatchlists()
|
refreshWatchlists()
|
||||||
|
getConnectors().then(c => setConnectors(c['hydra:member']))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <Flex gap="middle" align="center" justify="center" vertical>
|
return <Flex gap="middle" align="center" justify="center" vertical>
|
||||||
<Card title={t`Create a Watchlist`} style={{width: '100%'}}>
|
<Card title={t`Create a Watchlist`} style={{width: '100%'}}>
|
||||||
{contextHolder}
|
{contextHolder}
|
||||||
<WatchlistForm form={form} onCreateWatchlist={onCreateWatchlist}/>
|
{
|
||||||
|
connectors &&
|
||||||
|
<WatchlistForm form={form} onCreateWatchlist={onCreateWatchlist} connectors={connectors}/>
|
||||||
|
}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {request} from "./index";
|
import {request} from "./index";
|
||||||
|
|
||||||
enum ConnectorProvider {
|
export enum ConnectorProvider {
|
||||||
OVH = 'ovh'
|
OVH = 'ovh'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ export async function getWatchlist(token: string) {
|
|||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postWatchlist(domains: string[], triggers: { action: string, event: EventAction }[]) {
|
export async function postWatchlist(domains: string[], triggers: {
|
||||||
|
action: string,
|
||||||
|
event: EventAction,
|
||||||
|
connector?: string
|
||||||
|
}[]) {
|
||||||
const response = await request<{ token: string }>({
|
const response = await request<{ token: string }>({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'watchlists',
|
url: 'watchlists',
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Entity\User;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Ovh\Api;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
@@ -56,7 +57,16 @@ class ConnectorController extends AbstractController
|
|||||||
$connector->setUser($this->getUser());
|
$connector->setUser($this->getUser());
|
||||||
|
|
||||||
if ($connector->getProvider() === ConnectorProvider::OVH) {
|
if ($connector->getProvider() === ConnectorProvider::OVH) {
|
||||||
$connector->setAuthData(OvhConnector::verifyAuthData($connector->getAuthData()));
|
$authData = OvhConnector::verifyAuthData($connector->getAuthData());
|
||||||
|
$connector->setAuthData($authData);
|
||||||
|
$ovh = new Api(
|
||||||
|
$authData['appKey'],
|
||||||
|
$authData['appSecret'],
|
||||||
|
$authData['apiEndpoint'],
|
||||||
|
$authData['consumerKey']
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
} else throw new Exception('Unknown provider');
|
} else throw new Exception('Unknown provider');
|
||||||
|
|
||||||
$this->em->persist($connector);
|
$this->em->persist($connector);
|
||||||
|
|||||||
@@ -63,12 +63,11 @@ final readonly class ProcessDomainTriggerHandler
|
|||||||
$ovh = new OVHConnector($connector->getAuthData());
|
$ovh = new OVHConnector($connector->getAuthData());
|
||||||
$isDebug = $this->kernel->isDebug();
|
$isDebug = $this->kernel->isDebug();
|
||||||
|
|
||||||
|
|
||||||
$ovh->orderDomain(
|
$ovh->orderDomain(
|
||||||
$domain,
|
$domain,
|
||||||
true,
|
true, // TODO: Infer from the user
|
||||||
true,
|
true, // TODO: Infer from the user
|
||||||
true,
|
true, // TODO: Infer from the user
|
||||||
$isDebug
|
$isDebug
|
||||||
);
|
);
|
||||||
$this->sendEmailDomainOrdered($domain, $connector, $watchList->getUser());
|
$this->sendEmailDomainOrdered($domain, $connector, $watchList->getUser());
|
||||||
|
|||||||
Reference in New Issue
Block a user