Module change_pswd_func.change_pswd

View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python

from .check_similarity import similar

from .find_pswd import find_pswd

from .log import LogMsgChangePaswd

from .verify_pswd import verify_pswd

def change_pswd(old_pswd: str, new_pswd: str) -> bool:

    if not find_pswd(old_pswd):

        '''

        [Change password requirement] 1. Old password should match with system

        '''

        print(LogMsgChangePaswd.INVALID_OLD_PSWD)

    elif not verify_pswd(new_pswd):

        '''

        [Change password requirement] 2. New password should be a valid password

        '''

        print(LogMsgChangePaswd.INVALID_NEW_PSWD)

    elif similar(old_pswd, new_pswd):

        '''

        [Change password requirement] 3. password is not similar to old password < 80% match.

        '''

        print(LogMsgChangePaswd.SIMILAR_TO_OLD_ONE)

    else:

        print(LogMsgChangePaswd.SUCCESS)

        return True

    return False

Functions

change_pswd

def change_pswd(
    old_pswd: str,
    new_pswd: str
) -> bool
View Source
def change_pswd(old_pswd: str, new_pswd: str) -> bool:

    if not find_pswd(old_pswd):

        '''

        [Change password requirement] 1. Old password should match with system

        '''

        print(LogMsgChangePaswd.INVALID_OLD_PSWD)

    elif not verify_pswd(new_pswd):

        '''

        [Change password requirement] 2. New password should be a valid password

        '''

        print(LogMsgChangePaswd.INVALID_NEW_PSWD)

    elif similar(old_pswd, new_pswd):

        '''

        [Change password requirement] 3. password is not similar to old password < 80% match.

        '''

        print(LogMsgChangePaswd.SIMILAR_TO_OLD_ONE)

    else:

        print(LogMsgChangePaswd.SUCCESS)

        return True

    return False