浏览代码

pass change

ivar_n 3 年之前
父节点
当前提交
d6f4f3287c
共有 6 个文件被更改,包括 23 次插入64 次删除
  1. 0 2
      src/App.js
  2. 10 9
      src/actions/authActions.js
  3. 8 8
      src/actions/chatsActions.js
  4. 0 1
      src/actions/index.js
  5. 0 1
      src/components/MsgDropZone.js
  6. 5 43
      src/components/ProfileModal.js

+ 0 - 2
src/App.js

@@ -13,7 +13,6 @@ import {
 import {
   actionAddChat, 
   actionUpdateChat,
-  actionRemoveChat,
   actionGetChatsByUser,
   actionGetAllChats,
 
@@ -68,7 +67,6 @@ function App() {
 
   // store.dispatch(actionAddChat('Титул'))
   // store.dispatch(actionUpdateChat("61dae9437b27dd2bab6072b6", 'ЗАЛУПА228', memb))
-  // store.dispatch(actionRemoveChat("61db41a9c8a65f1e90688adc"))
   // store.dispatch(actionGetChatsByUser("61d76d947b27dd2bab607273"))
   // store.dispatch(actionFullChatList("61d76d947b27dd2bab607273", 0))
 

+ 10 - 9
src/actions/authActions.js

@@ -86,22 +86,23 @@ import {
    )
 
 
-
-   const actionChangePass = (login, password, newPassword) => (
-      actionPromise('changePass', gql(`mutation changePass($login: String! $password: String! $newPassword: String!) {
-         changePassword(login: $login, password: $password, newPassword: $newPassword)
+   const actionChangePass = (_id, password) => (
+      actionPromise('register', gql(`mutation reg($user:UserInput) {
+         UserUpsert(user:$user) {
+         _id 
+         }
       }
-      `, {login, password, newPassword})      
+      `, {user: {_id, password}})      
       )
    )
 
-   export const actionSetUserPass = (password, newPassword) => (
+   export const actionSetUserPass = (password) => (
       async (dispatch, getState) => {
          let {auth} = getState()
-         let userLog = auth.payload?.sub?.login
+         let userId = auth.payload?.sub?.id
 
-         console.log(userLog, password, newPassword)
-         await dispatch(actionChangePass(userLog, password, newPassword))         
+         console.log(userId, password)
+         await dispatch(actionChangePass(userId, password))         
       }
    )
 

+ 8 - 8
src/actions/chatsActions.js

@@ -39,14 +39,14 @@ export const actionUpdateChat = (chatId, newTitle, newMemders) => (
    }`, { chat: {_id: chatId, title: newTitle, members: newMemders} }))
 )
 
-// ?????????
-export const actionRemoveChat = (chatId) => (
-   actionPromise('removeChat', gql(`mutation removeChat($chat:ChatInput) {
-      ChatDelete(chat:$chat) {
-         _id     
-      }
-   }`, { chat: {_id: chatId} }))
-)
+// не работает
+// export const actionRemoveChat = (chatId) => (
+//    actionPromise('removeChat', gql(`mutation removeChat($chat:ChatInput) {
+//       ChatDelete(chat:$chat) {
+//          _id     
+//       }
+//    }`, { chat: {_id: chatId} }))
+// )
 
 
 // поиск по значению в массиве объектов - { 'members._id': userId }

+ 0 - 1
src/actions/index.js

@@ -8,7 +8,6 @@ export {
 export {
    actionAddChat, 
    actionUpdateChat,
-   actionRemoveChat,
    actionGetChatsByUser,
    actionGetAllChats,
 

+ 0 - 1
src/components/MsgDropZone.js

@@ -6,7 +6,6 @@ import {
     actionUploadFile,
 } from "../actions"
 
-import {store} from "../reducers"
 
 
 const thumbsContainer = {

+ 5 - 43
src/components/ProfileModal.js

@@ -35,7 +35,9 @@ const styleModalParrent = {
 }
 
 
-const PassModal = ({onСonfirm, minPass='2', char=false, bigChar=false, number=false, regError}) => {
+const PassModal = ({ onСonfirm, minPass='2', 
+                     char=true, bigChar=false, 
+                     number=true, regError}) => {
    const [open, setOpen] = useState(false);
    const handleOpen = () => {
      setOpen(true);
@@ -44,10 +46,6 @@ const PassModal = ({onСonfirm, minPass='2', char=false, bigChar=false, number=f
      setOpen(false);
    }
 
-   const [oldPass, setOldPass] = useState('')
-   const [oldPassBlur, setOldPassBlur] = useState(false)
-   
-
    const [pass, setPass] = useState('')
    const [passBlur, setPassBlur] = useState(false)
 
@@ -120,41 +118,6 @@ const PassModal = ({onСonfirm, minPass='2', char=false, bigChar=false, number=f
                </IconButton>
             </Box>
 
-            <Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', mt: 4 }}>
-               <Typography variant="body1">
-                  Введите старый пароль
-               </Typography>
-               <TextField
-                  onChange={(e) => {
-                        e.target.value = e.target.value.trim()
-                        setOldPass(e.target.value.trim())
-                     }
-                  }  
-                  onBlur={() => {
-                        setOldPassBlur(true)              
-                     }
-                  } 
-                  onFocus={() => {
-                        setOldPassBlur(false)              
-                     }
-                  }
-                  error={oldPassBlur ? (checkPass(oldPass) ? false : true) : false}               
-                  helperText={printPassReq(oldPass)}            
-   
-                  inputProps={{
-                     maxLength: 100
-                     }}
-                  required
-                  variant="standard"
-                  margin="none"
-                  fullWidth
-                  name="password"
-                  label=""
-                  type="password"
-                  id="oldPasswordUser"
-                  sx={{mt: 1}}
-               />
-            </Box>
 
             <Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', mt: 4 }}>
                <Typography variant="body1">
@@ -239,11 +202,10 @@ const PassModal = ({onСonfirm, minPass='2', char=false, bigChar=false, number=f
 
             <Box sx={{ display: 'flex', justifyContent: 'end', mt: 2}}>
                <Button  variant="contained" 
-                        disabled={( checkPass(oldPass) && 
-                                    checkPass(pass) && 
+                        disabled={( checkPass(pass) && 
                                     pass === pass2 ) ? false : true}
 
-                        onClick={() => onСonfirm(oldPass, pass)}>
+                        onClick={() => onСonfirm(pass)}>
                   Изменить 
                </Button>
             </Box>