alexandrusoare commented on code in PR #33255:
URL: https://github.com/apache/superset/pull/33255#discussion_r2102027207


##########
superset/views/utils.py:
##########
@@ -71,8 +71,8 @@ def sanitize_datasource_data(datasource_data: dict[str, Any]) 
-> dict[str, Any]:
 def bootstrap_user_data(user: User, include_perms: bool = False) -> dict[str, 
Any]:
     if user.is_anonymous:
         payload = {}
-        user.roles = (security_manager.find_role("Public"),)
-    elif security_manager.is_guest_user(user):
+        user.roles = (current_app.appbuilder.sm.find_role("Public"),)
+    elif current_app.appbuilder.sm.is_guest_user(user):
         payload = {

Review Comment:
   Why do you need to use the `current_app.app_builder.sm` instead of 
`security_manager`



##########
superset-frontend/src/pages/Register/index.tsx:
##########
@@ -0,0 +1,211 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import { SupersetClient, styled, t, css } from '@superset-ui/core';
+import { Button, Card, Flex, Form, Input } from 'src/components';
+import { useState } from 'react';
+import getBootstrapData from 'src/utils/getBootstrapData';
+import ReactCAPTCHA from 'react-google-recaptcha';
+
+interface RegisterForm {
+  username: string;
+  firstName: string;
+  lastName: string;
+  email: string;
+  password: string;
+  confirmPassword: string;
+}
+
+const StyledCard = styled(Card)`
+  ${({ theme }) => css`
+    width: 50%;
+    margin-top: ${theme.marginXL}px;
+    background: ${theme.colorBgBase};
+    .antd5-form-item-label label {
+      color: ${theme.colorPrimary};
+    }
+  `}
+`;
+
+const formItemLayout = {
+  labelCol: {
+    xs: { span: 24 },
+    sm: { span: 6 },
+  },
+  wrapperCol: {
+    xs: { span: 24 },
+    sm: { span: 24 },
+  },
+};
+
+export default function Login() {
+  const [form] = Form.useForm<RegisterForm>();
+  const [loading, setLoading] = useState(false);
+  const [captchaResponse, setCaptchaResponse] = useState<string | null>(null);
+
+  const bootstrapData = getBootstrapData();
+
+  const authRecaptchaPublicKey: string =
+    bootstrapData.common.conf.RECAPTCHA_PUBLIC_KEY || '';
+
+  const onFinish = (values: RegisterForm) => {
+    setLoading(true);
+    const payload = {
+      username: values.username,
+      first_name: values.firstName,
+      last_name: values.lastName,
+      email: values.email,
+      password: values.password,
+      conf_password: values.confirmPassword,
+      'g-recaptcha-response': captchaResponse,
+    };
+    SupersetClient.postForm('/register/form', payload, '').finally(() => {
+      setLoading(false);
+    });
+  };
+  return (
+    <Flex
+      justify="center"
+      css={css`
+        width: 100%;
+      `}
+      data-test="register-form"
+    >
+      <StyledCard title={t('Fill out the registration form')} padded>
+        <Form form={form} onFinish={onFinish} {...formItemLayout}>
+          <Form.Item<RegisterForm>
+            label={t('Username')}
+            name="username"
+            rules={[
+              { required: true, message: t('Please enter your username') },
+            ]}
+          >
+            <Input
+              placeholder={t('Username')}
+              autoComplete="username"
+              data-test="username-input"
+            />
+          </Form.Item>
+          <Form.Item<RegisterForm>
+            label={t('First Name')}
+            name="firstName"
+            rules={[
+              { required: true, message: t('Please enter your first name') },
+            ]}
+          >
+            <Input
+              placeholder={t('First name')}
+              autoComplete="given-name"
+              data-test="first-name-input"
+            />
+          </Form.Item>
+          <Form.Item<RegisterForm>
+            label={t('Last Name')}
+            name="lastName"
+            rules={[
+              { required: true, message: t('Please enter your last name') },
+            ]}
+          >
+            <Input
+              placeholder={t('Last name')}
+              autoComplete="family-name"
+              data-test="last-name-input"
+            />
+          </Form.Item>
+          <Form.Item<RegisterForm>
+            label={t('Email')}
+            name="email"
+            rules={[{ required: true, message: t('Please enter your email') }]}
+          >

Review Comment:
   ```suggestion
             >rules={[
                 { required: true, message: t('Email is required') },
                 {
                   type: 'email',
                   message: t('Please enter a valid email address'),
                 },
               ]}
   ```



##########
superset-frontend/src/pages/Login/index.tsx:
##########
@@ -0,0 +1,213 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import { SupersetClient, styled, t, css } from '@superset-ui/core';
+import {
+  Button,
+  Card,
+  Flex,
+  Form,
+  Input,
+  Typography,
+  Icons,
+} from 'src/components';
+import { useState } from 'react';
+import { capitalize } from 'lodash/fp';
+import getBootstrapData from 'src/utils/getBootstrapData';
+
+type OAuthProvider = {
+  name: string;
+  icon: string;
+};
+
+type OIDProvider = {
+  name: string;
+  url: string;
+};
+
+type Provider = OAuthProvider | OIDProvider;
+
+interface LoginForm {
+  username: string;
+  password: string;
+}
+
+enum AuthType {
+  AuthOID = 0,
+  AuthDB = 1,
+  AuthLDAP = 2,
+  AuthOauth = 4,
+}
+
+const AuthIconMap: Record<string, React.JSX.Element> = {
+  github: <Icons.GithubOutlined />,
+  google: <Icons.GoogleOutlined />,
+  facebook: <Icons.FacebookOutlined />,
+};
+
+const StyledCard = styled(Card)`
+  ${({ theme }) => css`
+    width: 40%;

Review Comment:
   I would avoid using percentages as I don't think it would look great on wide 
screens, let me know what you think



##########
superset-frontend/src/pages/Register/index.tsx:
##########
@@ -0,0 +1,211 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import { SupersetClient, styled, t, css } from '@superset-ui/core';
+import { Button, Card, Flex, Form, Input } from 'src/components';
+import { useState } from 'react';
+import getBootstrapData from 'src/utils/getBootstrapData';
+import ReactCAPTCHA from 'react-google-recaptcha';
+
+interface RegisterForm {
+  username: string;
+  firstName: string;
+  lastName: string;
+  email: string;
+  password: string;
+  confirmPassword: string;
+}
+
+const StyledCard = styled(Card)`
+  ${({ theme }) => css`
+    width: 50%;
+    margin-top: ${theme.marginXL}px;
+    background: ${theme.colorBgBase};
+    .antd5-form-item-label label {
+      color: ${theme.colorPrimary};
+    }
+  `}
+`;
+
+const formItemLayout = {
+  labelCol: {
+    xs: { span: 24 },
+    sm: { span: 6 },
+  },
+  wrapperCol: {
+    xs: { span: 24 },
+    sm: { span: 24 },
+  },
+};
+
+export default function Login() {
+  const [form] = Form.useForm<RegisterForm>();
+  const [loading, setLoading] = useState(false);
+  const [captchaResponse, setCaptchaResponse] = useState<string | null>(null);
+
+  const bootstrapData = getBootstrapData();
+
+  const authRecaptchaPublicKey: string =
+    bootstrapData.common.conf.RECAPTCHA_PUBLIC_KEY || '';
+
+  const onFinish = (values: RegisterForm) => {
+    setLoading(true);
+    const payload = {
+      username: values.username,
+      first_name: values.firstName,
+      last_name: values.lastName,
+      email: values.email,
+      password: values.password,
+      conf_password: values.confirmPassword,
+      'g-recaptcha-response': captchaResponse,
+    };
+    SupersetClient.postForm('/register/form', payload, '').finally(() => {
+      setLoading(false);
+    });
+  };
+  return (
+    <Flex
+      justify="center"
+      css={css`
+        width: 100%;
+      `}
+      data-test="register-form"
+    >
+      <StyledCard title={t('Fill out the registration form')} padded>
+        <Form form={form} onFinish={onFinish} {...formItemLayout}>
+          <Form.Item<RegisterForm>
+            label={t('Username')}
+            name="username"
+            rules={[
+              { required: true, message: t('Please enter your username') },
+            ]}
+          >
+            <Input
+              placeholder={t('Username')}
+              autoComplete="username"
+              data-test="username-input"
+            />
+          </Form.Item>
+          <Form.Item<RegisterForm>
+            label={t('First Name')}
+            name="firstName"
+            rules={[
+              { required: true, message: t('Please enter your first name') },
+            ]}
+          >
+            <Input
+              placeholder={t('First name')}
+              autoComplete="given-name"
+              data-test="first-name-input"
+            />
+          </Form.Item>
+          <Form.Item<RegisterForm>
+            label={t('Last Name')}
+            name="lastName"
+            rules={[
+              { required: true, message: t('Please enter your last name') },
+            ]}
+          >
+            <Input
+              placeholder={t('Last name')}
+              autoComplete="family-name"
+              data-test="last-name-input"
+            />
+          </Form.Item>
+          <Form.Item<RegisterForm>
+            label={t('Email')}
+            name="email"
+            rules={[{ required: true, message: t('Please enter your email') }]}
+          >

Review Comment:
   So that it can check if t s valid format for the email adress as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to